diff --git a/Plugins/Opus/Opus/OpusDecoder.h b/Plugins/Opus/Opus/OpusDecoder.h index f39647187..b983d84dc 100644 --- a/Plugins/Opus/Opus/OpusDecoder.h +++ b/Plugins/Opus/Opus/OpusDecoder.h @@ -34,6 +34,11 @@ float replayGainAlbumGain; float replayGainTrackGain; + NSString *icygenre; + NSString *icyalbum; + NSString *icyartist; + NSString *icytitle; + NSData *albumArt; } diff --git a/Plugins/Opus/Opus/OpusDecoder.m b/Plugins/Opus/Opus/OpusDecoder.m index b71ac613a..6aa435bde 100644 --- a/Plugins/Opus/Opus/OpusDecoder.m +++ b/Plugins/Opus/Opus/OpusDecoder.m @@ -14,6 +14,8 @@ #import "HTTPSource.h" +#import "NSDictionary+Merge.h" + @implementation OpusFile static const int MAXCHANNELS = 8; @@ -124,6 +126,10 @@ opus_int64 sourceTell(void *_stream) { album = @""; title = @""; genre = @""; + icygenre = @""; + icyalbum = @""; + icyartist = @""; + icytitle = @""; year = @(0); track = @(0); disc = @(0); @@ -233,10 +239,10 @@ opus_int64 sourceTell(void *_stream) { - (void)updateIcyMetadata { if([source seekable]) return; - NSString *_genre = genre; - NSString *_album = album; - NSString *_artist = artist; - NSString *_title = title; + NSString *_genre = icygenre; + NSString *_album = icyalbum; + NSString *_artist = icyartist; + NSString *_title = icytitle; Class sourceClass = [source class]; if([sourceClass isEqual:NSClassFromString(@"HTTPSource")]) { @@ -250,14 +256,14 @@ opus_int64 sourceTell(void *_stream) { } } - if(![_genre isEqual:genre] || - ![_album isEqual:album] || - ![_artist isEqual:artist] || - ![_title isEqual:title]) { - genre = _genre; - album = _album; - artist = _artist; - title = _title; + if(![_genre isEqual:icygenre] || + ![_album isEqual:icyalbum] || + ![_artist isEqual:icyartist] || + ![_title isEqual:icytitle]) { + icygenre = _genre; + icyalbum = _album; + icyartist = _artist; + icytitle = _title; [self willChangeValueForKey:@"metadata"]; [self didChangeValueForKey:@"metadata"]; } @@ -340,7 +346,7 @@ opus_int64 sourceTell(void *_stream) { } - (NSDictionary *)metadata { - return @{ @"artist": artist, @"albumartist": albumartist, @"album": album, @"title": title, @"genre": genre, @"year": year, @"track": track, @"disc": disc, @"albumArt": albumArt }; + return [@{ @"artist": artist, @"albumartist": albumartist, @"album": album, @"title": title, @"genre": genre, @"year": year, @"track": track, @"disc": disc, @"albumArt": albumArt } dictionaryByMergingWith:@{ @"genre": icygenre, @"album": icyalbum, @"artist": icyartist, @"title": icytitle }]; } + (NSArray *)fileTypes { diff --git a/Plugins/Opus/OpusPlugin.xcodeproj/project.pbxproj b/Plugins/Opus/OpusPlugin.xcodeproj/project.pbxproj index 58e393697..73b17471e 100644 --- a/Plugins/Opus/OpusPlugin.xcodeproj/project.pbxproj +++ b/Plugins/Opus/OpusPlugin.xcodeproj/project.pbxproj @@ -7,6 +7,7 @@ objects = { /* Begin PBXBuildFile section */ + 83186316285CEC91001422CC /* NSDictionary+Merge.m in Sources */ = {isa = PBXBuildFile; fileRef = 83186315285CEC91001422CC /* NSDictionary+Merge.m */; }; 836EF0CF27BB952F00BF35B2 /* libopusfile.0.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 836EF0CE27BB952F00BF35B2 /* libopusfile.0.dylib */; }; 8375B04017FFEA400092A79F /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8375B03F17FFEA400092A79F /* Cocoa.framework */; }; 8375B04A17FFEA400092A79F /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 8375B04817FFEA400092A79F /* InfoPlist.strings */; }; @@ -26,6 +27,8 @@ /* End PBXCopyFilesBuildPhase section */ /* Begin PBXFileReference section */ + 83186314285CEC91001422CC /* NSDictionary+Merge.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "NSDictionary+Merge.h"; path = "../../../Utils/NSDictionary+Merge.h"; sourceTree = ""; }; + 83186315285CEC91001422CC /* NSDictionary+Merge.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "NSDictionary+Merge.m"; path = "../../../Utils/NSDictionary+Merge.m"; sourceTree = ""; }; 833F68411CDBCABC00AFB9F0 /* es */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = es; path = es.lproj/InfoPlist.strings; sourceTree = ""; }; 8356BD1B27B469B80074E50C /* HTTPSource.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = HTTPSource.h; path = ../../HTTPSource/HTTPSource.h; sourceTree = ""; }; 836EF0CE27BB952F00BF35B2 /* libopusfile.0.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libopusfile.0.dylib; path = ../../ThirdParty/opusfile/lib/libopusfile.0.dylib; sourceTree = ""; }; @@ -96,6 +99,8 @@ 8375B04517FFEA400092A79F /* Opus */ = { isa = PBXGroup; children = ( + 83186314285CEC91001422CC /* NSDictionary+Merge.h */, + 83186315285CEC91001422CC /* NSDictionary+Merge.m */, 8356BD1B27B469B80074E50C /* HTTPSource.h */, 8384913718081F2700E7332D /* Logging.h */, 8375B36D17FFF1FE0092A79F /* Plugin.h */, @@ -188,6 +193,7 @@ buildActionMask = 2147483647; files = ( 8375B36C17FFF1CB0092A79F /* OpusDecoder.m in Sources */, + 83186316285CEC91001422CC /* NSDictionary+Merge.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/Plugins/Vorbis/VorbisDecoder.h b/Plugins/Vorbis/VorbisDecoder.h index 18a75d7a0..3c5806e71 100644 --- a/Plugins/Vorbis/VorbisDecoder.h +++ b/Plugins/Vorbis/VorbisDecoder.h @@ -45,6 +45,11 @@ float replayGainTrackGain; float replayGainTrackPeak; + NSString *icygenre; + NSString *icyalbum; + NSString *icyartist; + NSString *icytitle; + NSData *albumArt; } diff --git a/Plugins/Vorbis/VorbisDecoder.m b/Plugins/Vorbis/VorbisDecoder.m index 5f7bb6ba0..c40796fcd 100644 --- a/Plugins/Vorbis/VorbisDecoder.m +++ b/Plugins/Vorbis/VorbisDecoder.m @@ -14,6 +14,8 @@ #import "picture.h" +#import "NSDictionary+Merge.h" + @implementation VorbisDecoder static const int MAXCHANNELS = 8; @@ -104,6 +106,10 @@ long sourceTell(void *datasource) { album = @""; title = @""; genre = @""; + icygenre = @""; + icyalbum = @""; + icyartist = @""; + icytitle = @""; year = @(0); track = @(0); disc = @(0); @@ -211,10 +217,10 @@ long sourceTell(void *datasource) { - (void)updateIcyMetadata { if([source seekable]) return; - NSString *_genre = genre; - NSString *_album = album; - NSString *_artist = artist; - NSString *_title = title; + NSString *_genre = icygenre; + NSString *_album = icyalbum; + NSString *_artist = icyartist; + NSString *_title = icytitle; Class sourceClass = [source class]; if([sourceClass isEqual:NSClassFromString(@"HTTPSource")]) { @@ -228,14 +234,14 @@ long sourceTell(void *datasource) { } } - if(![_genre isEqual:genre] || - ![_album isEqual:album] || - ![_artist isEqual:artist] || - ![_title isEqual:title]) { - genre = _genre; - album = _album; - artist = _artist; - title = _title; + if(![_genre isEqual:icygenre] || + ![_album isEqual:icyalbum] || + ![_artist isEqual:icyartist] || + ![_title isEqual:icytitle]) { + icygenre = _genre; + icyalbum = _album; + icyartist = _artist; + icytitle = _title; [self willChangeValueForKey:@"metadata"]; [self didChangeValueForKey:@"metadata"]; } @@ -319,7 +325,7 @@ long sourceTell(void *datasource) { } - (NSDictionary *)metadata { - return @{ @"artist": artist, @"albumartist": albumartist, @"album": album, @"title": title, @"genre": genre, @"year": year, @"track": track, @"disc": disc, @"albumArt": albumArt }; + return [@{ @"artist": artist, @"albumartist": albumartist, @"album": album, @"title": title, @"genre": genre, @"year": year, @"track": track, @"disc": disc, @"albumArt": albumArt } dictionaryByMergingWith:@{ @"genre": icygenre, @"album": icyalbum, @"artist": icyartist, @"title": icytitle }]; } + (NSArray *)fileTypes { diff --git a/Plugins/Vorbis/VorbisPlugin.xcodeproj/project.pbxproj b/Plugins/Vorbis/VorbisPlugin.xcodeproj/project.pbxproj index 610e11b0c..e566bc7d8 100644 --- a/Plugins/Vorbis/VorbisPlugin.xcodeproj/project.pbxproj +++ b/Plugins/Vorbis/VorbisPlugin.xcodeproj/project.pbxproj @@ -8,6 +8,7 @@ /* Begin PBXBuildFile section */ 17C93D360B8FDA66008627D6 /* VorbisDecoder.m in Sources */ = {isa = PBXBuildFile; fileRef = 17C93D340B8FDA66008627D6 /* VorbisDecoder.m */; }; + 83186313285CEBD2001422CC /* NSDictionary+Merge.m in Sources */ = {isa = PBXBuildFile; fileRef = 83186312285CEBD2001422CC /* NSDictionary+Merge.m */; }; 836EF0D627BB969D00BF35B2 /* libvorbisfile.3.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 836EF0D427BB969D00BF35B2 /* libvorbisfile.3.dylib */; }; 836EF0DF27BB987000BF35B2 /* libvorbis.0.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 836EF0DE27BB987000BF35B2 /* libvorbis.0.dylib */; }; 83AA661627B7FAFC0098D4B8 /* picture.c in Sources */ = {isa = PBXBuildFile; fileRef = 83AA661127B7FAFC0098D4B8 /* picture.c */; }; @@ -23,6 +24,8 @@ 17C93D330B8FDA66008627D6 /* VorbisDecoder.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = VorbisDecoder.h; sourceTree = ""; }; 17C93D340B8FDA66008627D6 /* VorbisDecoder.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; path = VorbisDecoder.m; sourceTree = ""; }; 32DBCF630370AF2F00C91783 /* VorbisPlugin_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VorbisPlugin_Prefix.pch; sourceTree = ""; }; + 83186311285CEBD2001422CC /* NSDictionary+Merge.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "NSDictionary+Merge.h"; path = "../../Utils/NSDictionary+Merge.h"; sourceTree = ""; }; + 83186312285CEBD2001422CC /* NSDictionary+Merge.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "NSDictionary+Merge.m"; path = "../../Utils/NSDictionary+Merge.m"; sourceTree = ""; }; 8356BD1C27B46A2D0074E50C /* HTTPSource.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = HTTPSource.h; path = ../HTTPSource/HTTPSource.h; sourceTree = ""; }; 836EF0D427BB969D00BF35B2 /* libvorbisfile.3.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libvorbisfile.3.dylib; path = ../../ThirdParty/vorbis/lib/libvorbisfile.3.dylib; sourceTree = ""; }; 836EF0DE27BB987000BF35B2 /* libvorbis.0.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libvorbis.0.dylib; path = ../../ThirdParty/vorbis/lib/libvorbis.0.dylib; sourceTree = ""; }; @@ -84,6 +87,8 @@ 08FB77AFFE84173DC02AAC07 /* Classes */ = { isa = PBXGroup; children = ( + 83186311285CEBD2001422CC /* NSDictionary+Merge.h */, + 83186312285CEBD2001422CC /* NSDictionary+Merge.m */, 8356BD1C27B46A2D0074E50C /* HTTPSource.h */, 8384913418081A3900E7332D /* Logging.h */, 177FCF9D0B90C9530011C3B5 /* Plugin.h */, @@ -250,6 +255,7 @@ buildActionMask = 2147483647; files = ( 83AA661627B7FAFC0098D4B8 /* picture.c in Sources */, + 83186313285CEBD2001422CC /* NSDictionary+Merge.m in Sources */, 83AA661727B7FAFD0098D4B8 /* base64.c in Sources */, 17C93D360B8FDA66008627D6 /* VorbisDecoder.m in Sources */, );