FFmpeg/FLAC/Opus/Vorbis Inputs: Fix metadata

The dynamic metadata functions should only activate for unseekable
streams, not seekable streams, and not local files.

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
This commit is contained in:
Christopher Snowhill 2022-02-09 15:04:49 -08:00
parent 0012d1b17e
commit e2e83ea760
4 changed files with 39 additions and 27 deletions

View file

@ -461,6 +461,8 @@ int64_t ffmpeg_seek(void *opaque, int64_t offset, int whence) {
} }
- (void)updateMetadata { - (void)updateMetadata {
if([source seekable]) return;
const AVDictionaryEntry *tag = NULL; const AVDictionaryEntry *tag = NULL;
NSString *_genre = genre; NSString *_genre = genre;
NSString *_album = album; NSString *_album = album;

View file

@ -230,10 +230,11 @@ void MetadataCallback(const FLAC__StreamDecoder *decoder, const FLAC__StreamMeta
} }
} }
if(![_genre isEqual:flacDecoder->genre] || if(![flacDecoder->source seekable] &&
(![_genre isEqual:flacDecoder->genre] ||
![_album isEqual:flacDecoder->album] || ![_album isEqual:flacDecoder->album] ||
![_artist isEqual:flacDecoder->artist] || ![_artist isEqual:flacDecoder->artist] ||
![_title isEqual:flacDecoder->title]) { ![_title isEqual:flacDecoder->title])) {
flacDecoder->genre = _genre; flacDecoder->genre = _genre;
flacDecoder->album = _album; flacDecoder->album = _album;
flacDecoder->artist = _artist; flacDecoder->artist = _artist;
@ -365,6 +366,7 @@ void ErrorCallback(const FLAC__StreamDecoder *decoder, FLAC__StreamDecoderErrorS
} }
} }
if(![source seekable]) {
Class sourceClass = [source class]; Class sourceClass = [source class];
if([sourceClass isEqual:NSClassFromString(@"HTTPSource")]) { if([sourceClass isEqual:NSClassFromString(@"HTTPSource")]) {
HTTPSource *httpSource = (HTTPSource *)source; HTTPSource *httpSource = (HTTPSource *)source;
@ -387,6 +389,7 @@ void ErrorCallback(const FLAC__StreamDecoder *decoder, FLAC__StreamDecoderErrorS
} }
} }
} }
}
return framesRead; return framesRead;
} }

View file

@ -158,10 +158,11 @@ opus_int64 sourceTell(void *_stream) {
} }
} }
if(![_genre isEqual:genre] || if(![source seekable] &&
(![_genre isEqual:genre] ||
![_album isEqual:album] || ![_album isEqual:album] ||
![_artist isEqual:artist] || ![_artist isEqual:artist] ||
![_title isEqual:title]) { ![_title isEqual:title])) {
genre = _genre; genre = _genre;
album = _album; album = _album;
artist = _artist; artist = _artist;
@ -173,6 +174,8 @@ opus_int64 sourceTell(void *_stream) {
} }
- (void)updateIcyMetadata { - (void)updateIcyMetadata {
if([source seekable]) return;
NSString *_genre = genre; NSString *_genre = genre;
NSString *_album = album; NSString *_album = album;
NSString *_artist = artist; NSString *_artist = artist;

View file

@ -107,6 +107,8 @@ long sourceTell(void *datasource) {
} }
- (void)updateMetadata { - (void)updateMetadata {
if([source seekable]) return;
const vorbis_comment *comment = ov_comment(&vorbisRef, -1); const vorbis_comment *comment = ov_comment(&vorbisRef, -1);
if(comment) { if(comment) {
@ -153,6 +155,8 @@ long sourceTell(void *datasource) {
} }
- (void)updateIcyMetadata { - (void)updateIcyMetadata {
if([source seekable]) return;
NSString *_genre = genre; NSString *_genre = genre;
NSString *_album = album; NSString *_album = album;
NSString *_artist = artist; NSString *_artist = artist;