From 380993ff16e72aec5e27ac3316662557327190c6 Mon Sep 17 00:00:00 2001 From: Chris Moeller Date: Mon, 7 Oct 2013 16:15:15 -0700 Subject: [PATCH] Move forced metadata lookup to PlaybackController so ReplayGain information will always be available when it's needed --- Application/PlaybackController.h | 2 + Application/PlaybackController.m | 11 +++++ Application/PlaybackEventController.h | 2 - Application/PlaybackEventController.m | 6 --- Cog.xcodeproj/project.pbxproj | 8 ++-- English.lproj/MainMenu.xib | 59 +++++++++++++-------------- 6 files changed, 45 insertions(+), 43 deletions(-) diff --git a/Application/PlaybackController.h b/Application/PlaybackController.h index a9871c9a9..6dd124768 100644 --- a/Application/PlaybackController.h +++ b/Application/PlaybackController.h @@ -18,11 +18,13 @@ extern NSDictionary * makeRGInfo(PlaylistEntry *pe); @class PlaylistController; @class PlaylistView; +@class PlaylistLoader; @interface PlaybackController : NSObject { IBOutlet PlaylistController *playlistController; IBOutlet PlaylistView *playlistView; + IBOutlet PlaylistLoader *playlistLoader; IBOutlet NSSlider *volumeSlider; diff --git a/Application/PlaybackController.m b/Application/PlaybackController.m index c1df6b290..6583c90e6 100644 --- a/Application/PlaybackController.m +++ b/Application/PlaybackController.m @@ -6,6 +6,7 @@ #import "PlaylistController.h" #import "PlaylistEntry.h" +#import "playlistLoader.h" @implementation PlaybackController @@ -146,6 +147,11 @@ NSDictionary * makeRGInfo(PlaylistEntry *pe) if (pe == nil) return; + // Race here, but the worst that could happen is we re-read the data + if ([pe metadataLoaded] != YES) { + [pe performSelectorOnMainThread:@selector(setMetadata:) withObject:[playlistLoader readEntryInfo:pe] waitUntilDone:YES]; + } + [audioPlayer play:[pe URL] withUserInfo:pe withRGInfo:makeRGInfo(pe)]; } @@ -456,7 +462,12 @@ NSDictionary * makeRGInfo(PlaylistEntry *pe) if (curEntry.stopAfter) pe = nil; else + { pe = [playlistController getNextEntry:curEntry]; + if ([pe metadataLoaded] != YES) { + [pe performSelectorOnMainThread:@selector(setMetadata:) withObject:[playlistLoader readEntryInfo:pe] waitUntilDone:YES]; + } + } [player setNextStream:[pe URL] withUserInfo:pe withRGInfo:makeRGInfo(pe)]; } diff --git a/Application/PlaybackEventController.h b/Application/PlaybackEventController.h index e39302c45..be167afc5 100644 --- a/Application/PlaybackEventController.h +++ b/Application/PlaybackEventController.h @@ -9,13 +9,11 @@ #import #import -@class PlaylistLoader; @class AudioScrobbler; @interface PlaybackEventController : NSObject { NSOperationQueue *queue; AudioScrobbler *scrobbler; - IBOutlet PlaylistLoader *playlistLoader; } @end diff --git a/Application/PlaybackEventController.m b/Application/PlaybackEventController.m index 56b9f7c62..fc6c7cbc8 100644 --- a/Application/PlaybackEventController.m +++ b/Application/PlaybackEventController.m @@ -10,7 +10,6 @@ #import "AudioScrobbler.h" #import "PlaybackController.h" -#import "PlaylistLoader.h" #import "PlaylistEntry.h" @implementation PlaybackEventController @@ -51,11 +50,6 @@ - (void)performPlaybackDidBeginActions:(PlaylistEntry *)pe { - // Race here, but the worst that could happen is we re-read the data - if ([pe metadataLoaded] != YES) { - [pe performSelectorOnMainThread:@selector(setMetadata:) withObject:[playlistLoader readEntryInfo:pe] waitUntilDone:YES]; - } - if (NO == [pe error]) { if([[NSUserDefaults standardUserDefaults] boolForKey:@"enableAudioScrobbler"]) { [scrobbler start:pe]; diff --git a/Cog.xcodeproj/project.pbxproj b/Cog.xcodeproj/project.pbxproj index 2cf9e577b..78e2f6847 100644 --- a/Cog.xcodeproj/project.pbxproj +++ b/Cog.xcodeproj/project.pbxproj @@ -1605,6 +1605,10 @@ ProductGroup = 17C8F7D30CBEF3E8008D969D /* Products */; ProjectRef = 17C8F7D20CBEF3E8008D969D /* Dumb.xcodeproj */; }, + { + ProductGroup = B09E94310D747F7B0064F138 /* Products */; + ProjectRef = B09E94300D747F7B0064F138 /* FFMPEG.xcodeproj */; + }, { ProductGroup = 17C808720C3BD167005707C4 /* Products */; ProjectRef = 17C808710C3BD167005707C4 /* FileSource.xcodeproj */; @@ -1669,10 +1673,6 @@ ProductGroup = 17C808C10C3BD1DD005707C4 /* Products */; ProjectRef = 17C808C00C3BD1DD005707C4 /* WavPack.xcodeproj */; }, - { - ProductGroup = B09E94310D747F7B0064F138 /* Products */; - ProjectRef = B09E94300D747F7B0064F138 /* FFMPEG.xcodeproj */; - }, ); projectRoot = ""; targets = ( diff --git a/English.lproj/MainMenu.xib b/English.lproj/MainMenu.xib index 02d999ece..407f37b83 100644 --- a/English.lproj/MainMenu.xib +++ b/English.lproj/MainMenu.xib @@ -1,5 +1,5 @@ - + @@ -82,7 +82,7 @@ - + @@ -354,19 +354,19 @@ - - artist contains[cd] $value Album + artist contains[cd] $value + - - genre contains[cd] $value Genre + genre contains[cd] $value + @@ -383,7 +383,7 @@ - + @@ -579,7 +579,7 @@ - + @@ -1042,8 +1042,8 @@ NSIsNotNil - + @@ -1093,8 +1093,8 @@ CA NSIsNotNil - + @@ -1130,11 +1130,11 @@ CA - + RepeatAllTransformer - + @@ -1156,11 +1156,11 @@ CA - + RepeatOneTransformer - + @@ -1174,11 +1174,11 @@ CA - + RepeatNoneTransformer - + @@ -1353,11 +1353,7 @@ Gw - - - - - + @@ -1386,11 +1382,11 @@ Gw - + Not Playing - Not Playing + @@ -1400,11 +1396,11 @@ Gw - + Not Playing - Not Playing + @@ -1462,6 +1458,7 @@ Gw + @@ -1503,8 +1500,8 @@ Gw NSIsNotNil - + @@ -1518,8 +1515,8 @@ Gw NSIsNotNil - + @@ -1536,8 +1533,8 @@ Gw NSIsNotNil - + @@ -1551,8 +1548,8 @@ Gw NSIsNotNil - + @@ -1585,7 +1582,7 @@ Gw - + @@ -1642,7 +1639,7 @@ Gw - + YnBsaXN0MDDUAQIDBAUGRkdYJHZlcnNpb25YJG9iamVjdHNZJGFyY2hpdmVyVCR0b3ASAAGGoK8QDwcI ExQZHh8qKyw0NzpAQ1UkbnVsbNUJCgsMDQ4PEBESVk5TU2l6ZVYkY2xhc3NcTlNJbWFnZUZsYWdzVk5T