Move forced metadata lookup to PlaybackController so ReplayGain information will always be available when it's needed

CQTexperiment
Chris Moeller 2013-10-07 16:15:15 -07:00
parent cdafef8a9c
commit 380993ff16
6 changed files with 45 additions and 43 deletions

View File

@ -18,11 +18,13 @@ extern NSDictionary * makeRGInfo(PlaylistEntry *pe);
@class PlaylistController; @class PlaylistController;
@class PlaylistView; @class PlaylistView;
@class PlaylistLoader;
@interface PlaybackController : NSObject @interface PlaybackController : NSObject
{ {
IBOutlet PlaylistController *playlistController; IBOutlet PlaylistController *playlistController;
IBOutlet PlaylistView *playlistView; IBOutlet PlaylistView *playlistView;
IBOutlet PlaylistLoader *playlistLoader;
IBOutlet NSSlider *volumeSlider; IBOutlet NSSlider *volumeSlider;

View File

@ -6,6 +6,7 @@
#import "PlaylistController.h" #import "PlaylistController.h"
#import "PlaylistEntry.h" #import "PlaylistEntry.h"
#import "playlistLoader.h"
@implementation PlaybackController @implementation PlaybackController
@ -146,6 +147,11 @@ NSDictionary * makeRGInfo(PlaylistEntry *pe)
if (pe == nil) if (pe == nil)
return; 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)]; [audioPlayer play:[pe URL] withUserInfo:pe withRGInfo:makeRGInfo(pe)];
} }
@ -456,7 +462,12 @@ NSDictionary * makeRGInfo(PlaylistEntry *pe)
if (curEntry.stopAfter) if (curEntry.stopAfter)
pe = nil; pe = nil;
else else
{
pe = [playlistController getNextEntry:curEntry]; 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)]; [player setNextStream:[pe URL] withUserInfo:pe withRGInfo:makeRGInfo(pe)];
} }

View File

@ -9,13 +9,11 @@
#import <Cocoa/Cocoa.h> #import <Cocoa/Cocoa.h>
#import <Growl/GrowlApplicationBridge.h> #import <Growl/GrowlApplicationBridge.h>
@class PlaylistLoader;
@class AudioScrobbler; @class AudioScrobbler;
@interface PlaybackEventController : NSObject <GrowlApplicationBridgeDelegate> { @interface PlaybackEventController : NSObject <GrowlApplicationBridgeDelegate> {
NSOperationQueue *queue; NSOperationQueue *queue;
AudioScrobbler *scrobbler; AudioScrobbler *scrobbler;
IBOutlet PlaylistLoader *playlistLoader;
} }
@end @end

View File

@ -10,7 +10,6 @@
#import "AudioScrobbler.h" #import "AudioScrobbler.h"
#import "PlaybackController.h" #import "PlaybackController.h"
#import "PlaylistLoader.h"
#import "PlaylistEntry.h" #import "PlaylistEntry.h"
@implementation PlaybackEventController @implementation PlaybackEventController
@ -51,11 +50,6 @@
- (void)performPlaybackDidBeginActions:(PlaylistEntry *)pe - (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 (NO == [pe error]) {
if([[NSUserDefaults standardUserDefaults] boolForKey:@"enableAudioScrobbler"]) { if([[NSUserDefaults standardUserDefaults] boolForKey:@"enableAudioScrobbler"]) {
[scrobbler start:pe]; [scrobbler start:pe];

View File

@ -1605,6 +1605,10 @@
ProductGroup = 17C8F7D30CBEF3E8008D969D /* Products */; ProductGroup = 17C8F7D30CBEF3E8008D969D /* Products */;
ProjectRef = 17C8F7D20CBEF3E8008D969D /* Dumb.xcodeproj */; ProjectRef = 17C8F7D20CBEF3E8008D969D /* Dumb.xcodeproj */;
}, },
{
ProductGroup = B09E94310D747F7B0064F138 /* Products */;
ProjectRef = B09E94300D747F7B0064F138 /* FFMPEG.xcodeproj */;
},
{ {
ProductGroup = 17C808720C3BD167005707C4 /* Products */; ProductGroup = 17C808720C3BD167005707C4 /* Products */;
ProjectRef = 17C808710C3BD167005707C4 /* FileSource.xcodeproj */; ProjectRef = 17C808710C3BD167005707C4 /* FileSource.xcodeproj */;
@ -1669,10 +1673,6 @@
ProductGroup = 17C808C10C3BD1DD005707C4 /* Products */; ProductGroup = 17C808C10C3BD1DD005707C4 /* Products */;
ProjectRef = 17C808C00C3BD1DD005707C4 /* WavPack.xcodeproj */; ProjectRef = 17C808C00C3BD1DD005707C4 /* WavPack.xcodeproj */;
}, },
{
ProductGroup = B09E94310D747F7B0064F138 /* Products */;
ProjectRef = B09E94300D747F7B0064F138 /* FFMPEG.xcodeproj */;
},
); );
projectRoot = ""; projectRoot = "";
targets = ( targets = (

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?> <?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="4510" systemVersion="12F37" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none"> <document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="4510" systemVersion="12F45" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none">
<dependencies> <dependencies>
<deployment version="1050" defaultVersion="1060" identifier="macosx"/> <deployment version="1050" defaultVersion="1060" identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="4510"/> <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="4510"/>
@ -82,7 +82,7 @@
<color key="textColor" name="headerTextColor" catalog="System" colorSpace="catalog"/> <color key="textColor" name="headerTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="headerColor" catalog="System" colorSpace="catalog"/> <color key="backgroundColor" name="headerColor" catalog="System" colorSpace="catalog"/>
</tableHeaderCell> </tableHeaderCell>
<imageCell key="dataCell" controlSize="small" refusesFirstResponder="YES" alignment="left" imageScaling="proportionallyDown" image="F80A8C12-27F0-4575-9C0A-CE9017032213" id="1801"> <imageCell key="dataCell" controlSize="small" refusesFirstResponder="YES" alignment="left" imageScaling="proportionallyDown" image="D965DE51-1F62-4638-9E46-CD8ACABC7612" id="1801">
<font key="font" metaFont="system"/> <font key="font" metaFont="system"/>
</imageCell> </imageCell>
<tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/> <tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/>
@ -354,19 +354,19 @@
<binding destination="218" name="predicate4" keyPath="filterPredicate" previousBinding="1580" id="1582"> <binding destination="218" name="predicate4" keyPath="filterPredicate" previousBinding="1580" id="1582">
<dictionary key="options"> <dictionary key="options">
<integer key="NSValidatesImmediately" value="0"/> <integer key="NSValidatesImmediately" value="0"/>
<integer key="NSAlwaysPresentsApplicationModalAlerts" value="0"/>
<string key="NSPredicateFormat">artist contains[cd] $value</string>
<string key="NSDisplayName">Album</string> <string key="NSDisplayName">Album</string>
<string key="NSPredicateFormat">artist contains[cd] $value</string>
<integer key="NSRaisesForNotApplicableKeys" value="1"/> <integer key="NSRaisesForNotApplicableKeys" value="1"/>
<integer key="NSAlwaysPresentsApplicationModalAlerts" value="0"/>
</dictionary> </dictionary>
</binding> </binding>
<binding destination="218" name="predicate5" keyPath="filterPredicate" previousBinding="1582" id="1583"> <binding destination="218" name="predicate5" keyPath="filterPredicate" previousBinding="1582" id="1583">
<dictionary key="options"> <dictionary key="options">
<integer key="NSValidatesImmediately" value="0"/> <integer key="NSValidatesImmediately" value="0"/>
<integer key="NSAlwaysPresentsApplicationModalAlerts" value="0"/>
<string key="NSPredicateFormat">genre contains[cd] $value</string>
<string key="NSDisplayName">Genre</string> <string key="NSDisplayName">Genre</string>
<string key="NSPredicateFormat">genre contains[cd] $value</string>
<integer key="NSRaisesForNotApplicableKeys" value="1"/> <integer key="NSRaisesForNotApplicableKeys" value="1"/>
<integer key="NSAlwaysPresentsApplicationModalAlerts" value="0"/>
</dictionary> </dictionary>
</binding> </binding>
</connections> </connections>
@ -383,7 +383,7 @@
<segmentedCell key="cell" state="on" alignment="left" style="automatic" trackingMode="momentary" id="1538"> <segmentedCell key="cell" state="on" alignment="left" style="automatic" trackingMode="momentary" id="1538">
<font key="font" metaFont="system"/> <font key="font" metaFont="system"/>
<segments> <segments>
<segment toolTip="Previous" image="previous" width="24" selected="YES"/> <segment toolTip="Previous" image="previous" width="24"/>
<segment toolTip="Play" image="play" width="24" tag="1"/> <segment toolTip="Play" image="play" width="24" tag="1"/>
<segment toolTip="Next" image="next" width="24"/> <segment toolTip="Next" image="next" width="24"/>
</segments> </segments>
@ -579,7 +579,7 @@
<segmentedCell key="cell" state="on" alignment="left" style="automatic" trackingMode="momentary" id="2296"> <segmentedCell key="cell" state="on" alignment="left" style="automatic" trackingMode="momentary" id="2296">
<font key="font" metaFont="system"/> <font key="font" metaFont="system"/>
<segments> <segments>
<segment toolTip="Previous" image="previous" width="24" selected="YES"/> <segment toolTip="Previous" image="previous" width="24"/>
<segment toolTip="Play" image="play" width="24" tag="1"/> <segment toolTip="Play" image="play" width="24" tag="1"/>
<segment toolTip="Next" image="next" width="24"/> <segment toolTip="Next" image="next" width="24"/>
</segments> </segments>
@ -1042,8 +1042,8 @@
<string key="NSValueTransformerName">NSIsNotNil</string> <string key="NSValueTransformerName">NSIsNotNil</string>
<integer key="NSNotApplicablePlaceholder" value="0"/> <integer key="NSNotApplicablePlaceholder" value="0"/>
<integer key="NSNoSelectionPlaceholder" value="0"/> <integer key="NSNoSelectionPlaceholder" value="0"/>
<integer key="NSNullPlaceholder" value="0"/>
<integer key="NSMultipleValuesPlaceholder" value="0"/> <integer key="NSMultipleValuesPlaceholder" value="0"/>
<integer key="NSNullPlaceholder" value="0"/>
</dictionary> </dictionary>
</binding> </binding>
</connections> </connections>
@ -1093,8 +1093,8 @@ CA
<string key="NSValueTransformerName">NSIsNotNil</string> <string key="NSValueTransformerName">NSIsNotNil</string>
<integer key="NSNotApplicablePlaceholder" value="0"/> <integer key="NSNotApplicablePlaceholder" value="0"/>
<integer key="NSNoSelectionPlaceholder" value="0"/> <integer key="NSNoSelectionPlaceholder" value="0"/>
<integer key="NSNullPlaceholder" value="0"/>
<integer key="NSMultipleValuesPlaceholder" value="1"/> <integer key="NSMultipleValuesPlaceholder" value="1"/>
<integer key="NSNullPlaceholder" value="0"/>
</dictionary> </dictionary>
</binding> </binding>
</connections> </connections>
@ -1130,11 +1130,11 @@ CA
<dictionary key="options"> <dictionary key="options">
<integer key="NSConditionallySetsEnabled" value="0"/> <integer key="NSConditionallySetsEnabled" value="0"/>
<integer key="NSAlwaysPresentsApplicationModalAlerts" value="0"/> <integer key="NSAlwaysPresentsApplicationModalAlerts" value="0"/>
<integer key="NSAllowsEditingMultipleValuesSelection" value="0"/> <integer key="NSRaisesForNotApplicableKeys" value="1"/>
<string key="NSValueTransformerName">RepeatAllTransformer</string> <string key="NSValueTransformerName">RepeatAllTransformer</string>
<integer key="NSConditionallySetsHidden" value="0"/> <integer key="NSConditionallySetsHidden" value="0"/>
<integer key="NSValidatesImmediately" value="0"/> <integer key="NSValidatesImmediately" value="0"/>
<integer key="NSRaisesForNotApplicableKeys" value="1"/> <integer key="NSAllowsEditingMultipleValuesSelection" value="0"/>
</dictionary> </dictionary>
</binding> </binding>
</connections> </connections>
@ -1156,11 +1156,11 @@ CA
<dictionary key="options"> <dictionary key="options">
<integer key="NSConditionallySetsEnabled" value="0"/> <integer key="NSConditionallySetsEnabled" value="0"/>
<integer key="NSAlwaysPresentsApplicationModalAlerts" value="0"/> <integer key="NSAlwaysPresentsApplicationModalAlerts" value="0"/>
<integer key="NSAllowsEditingMultipleValuesSelection" value="0"/> <integer key="NSRaisesForNotApplicableKeys" value="1"/>
<string key="NSValueTransformerName">RepeatOneTransformer</string> <string key="NSValueTransformerName">RepeatOneTransformer</string>
<integer key="NSConditionallySetsHidden" value="0"/> <integer key="NSConditionallySetsHidden" value="0"/>
<integer key="NSValidatesImmediately" value="0"/> <integer key="NSValidatesImmediately" value="0"/>
<integer key="NSRaisesForNotApplicableKeys" value="1"/> <integer key="NSAllowsEditingMultipleValuesSelection" value="0"/>
</dictionary> </dictionary>
</binding> </binding>
</connections> </connections>
@ -1174,11 +1174,11 @@ CA
<dictionary key="options"> <dictionary key="options">
<integer key="NSConditionallySetsEnabled" value="0"/> <integer key="NSConditionallySetsEnabled" value="0"/>
<integer key="NSAlwaysPresentsApplicationModalAlerts" value="0"/> <integer key="NSAlwaysPresentsApplicationModalAlerts" value="0"/>
<integer key="NSAllowsEditingMultipleValuesSelection" value="0"/> <integer key="NSRaisesForNotApplicableKeys" value="1"/>
<string key="NSValueTransformerName">RepeatNoneTransformer</string> <string key="NSValueTransformerName">RepeatNoneTransformer</string>
<integer key="NSConditionallySetsHidden" value="0"/> <integer key="NSConditionallySetsHidden" value="0"/>
<integer key="NSValidatesImmediately" value="0"/> <integer key="NSValidatesImmediately" value="0"/>
<integer key="NSRaisesForNotApplicableKeys" value="1"/> <integer key="NSAllowsEditingMultipleValuesSelection" value="0"/>
</dictionary> </dictionary>
</binding> </binding>
</connections> </connections>
@ -1353,11 +1353,7 @@ Gw
<outlet property="playbackController" destination="705" id="2404"/> <outlet property="playbackController" destination="705" id="2404"/>
</connections> </connections>
</customObject> </customObject>
<customObject id="2405" customClass="PlaybackEventController"> <customObject id="2405" customClass="PlaybackEventController"/>
<connections>
<outlet property="playlistLoader" destination="1319" id="2407"/>
</connections>
</customObject>
<customObject id="226" userLabel="AppController" customClass="AppController"> <customObject id="226" userLabel="AppController" customClass="AppController">
<connections> <connections>
<outlet property="fileButton" destination="1631" id="1661"/> <outlet property="fileButton" destination="1631" id="1661"/>
@ -1386,11 +1382,11 @@ Gw
<connections> <connections>
<binding destination="1897" name="title" keyPath="content.artist" id="2085"> <binding destination="1897" name="title" keyPath="content.artist" id="2085">
<dictionary key="options"> <dictionary key="options">
<string key="NSMultipleValuesPlaceholder"></string> <string key="NSNullPlaceholder">Not Playing</string>
<string key="NSNotApplicablePlaceholder"></string> <string key="NSNotApplicablePlaceholder"></string>
<string key="NSNoSelectionPlaceholder"></string> <string key="NSNoSelectionPlaceholder"></string>
<string key="NSNullPlaceholder">Not Playing</string>
<integer key="NSRaisesForNotApplicableKeys" value="1"/> <integer key="NSRaisesForNotApplicableKeys" value="1"/>
<string key="NSMultipleValuesPlaceholder"></string>
</dictionary> </dictionary>
</binding> </binding>
</connections> </connections>
@ -1400,11 +1396,11 @@ Gw
<connections> <connections>
<binding destination="1897" name="title" keyPath="content.title" id="2083"> <binding destination="1897" name="title" keyPath="content.title" id="2083">
<dictionary key="options"> <dictionary key="options">
<string key="NSMultipleValuesPlaceholder"></string> <string key="NSNullPlaceholder">Not Playing</string>
<string key="NSNotApplicablePlaceholder"></string> <string key="NSNotApplicablePlaceholder"></string>
<string key="NSNoSelectionPlaceholder"></string> <string key="NSNoSelectionPlaceholder"></string>
<string key="NSNullPlaceholder">Not Playing</string>
<integer key="NSRaisesForNotApplicableKeys" value="1"/> <integer key="NSRaisesForNotApplicableKeys" value="1"/>
<string key="NSMultipleValuesPlaceholder"></string>
</dictionary> </dictionary>
</binding> </binding>
</connections> </connections>
@ -1462,6 +1458,7 @@ Gw
<customObject id="705" userLabel="PlaybackController" customClass="PlaybackController"> <customObject id="705" userLabel="PlaybackController" customClass="PlaybackController">
<connections> <connections>
<outlet property="playlistController" destination="218" id="706"/> <outlet property="playlistController" destination="218" id="706"/>
<outlet property="playlistLoader" destination="1319" id="Xj8-Y6-EjQ"/>
<outlet property="playlistView" destination="207" id="717"/> <outlet property="playlistView" destination="207" id="717"/>
<outlet property="volumeSlider" destination="1612" id="1615"/> <outlet property="volumeSlider" destination="1612" id="1615"/>
</connections> </connections>
@ -1503,8 +1500,8 @@ Gw
<string key="NSValueTransformerName">NSIsNotNil</string> <string key="NSValueTransformerName">NSIsNotNil</string>
<integer key="NSNotApplicablePlaceholder" value="0"/> <integer key="NSNotApplicablePlaceholder" value="0"/>
<integer key="NSNoSelectionPlaceholder" value="0"/> <integer key="NSNoSelectionPlaceholder" value="0"/>
<integer key="NSNullPlaceholder" value="0"/>
<integer key="NSMultipleValuesPlaceholder" value="0"/> <integer key="NSMultipleValuesPlaceholder" value="0"/>
<integer key="NSNullPlaceholder" value="0"/>
</dictionary> </dictionary>
</binding> </binding>
</connections> </connections>
@ -1518,8 +1515,8 @@ Gw
<string key="NSValueTransformerName">NSIsNotNil</string> <string key="NSValueTransformerName">NSIsNotNil</string>
<integer key="NSNotApplicablePlaceholder" value="0"/> <integer key="NSNotApplicablePlaceholder" value="0"/>
<integer key="NSNoSelectionPlaceholder" value="0"/> <integer key="NSNoSelectionPlaceholder" value="0"/>
<integer key="NSNullPlaceholder" value="0"/>
<integer key="NSMultipleValuesPlaceholder" value="0"/> <integer key="NSMultipleValuesPlaceholder" value="0"/>
<integer key="NSNullPlaceholder" value="0"/>
</dictionary> </dictionary>
</binding> </binding>
</connections> </connections>
@ -1536,8 +1533,8 @@ Gw
<string key="NSValueTransformerName">NSIsNotNil</string> <string key="NSValueTransformerName">NSIsNotNil</string>
<integer key="NSNotApplicablePlaceholder" value="0"/> <integer key="NSNotApplicablePlaceholder" value="0"/>
<integer key="NSNoSelectionPlaceholder" value="0"/> <integer key="NSNoSelectionPlaceholder" value="0"/>
<integer key="NSNullPlaceholder" value="0"/>
<integer key="NSMultipleValuesPlaceholder" value="0"/> <integer key="NSMultipleValuesPlaceholder" value="0"/>
<integer key="NSNullPlaceholder" value="0"/>
</dictionary> </dictionary>
</binding> </binding>
</connections> </connections>
@ -1551,8 +1548,8 @@ Gw
<string key="NSValueTransformerName">NSIsNotNil</string> <string key="NSValueTransformerName">NSIsNotNil</string>
<integer key="NSNotApplicablePlaceholder" value="0"/> <integer key="NSNotApplicablePlaceholder" value="0"/>
<integer key="NSNoSelectionPlaceholder" value="0"/> <integer key="NSNoSelectionPlaceholder" value="0"/>
<integer key="NSNullPlaceholder" value="0"/>
<integer key="NSMultipleValuesPlaceholder" value="0"/> <integer key="NSMultipleValuesPlaceholder" value="0"/>
<integer key="NSNullPlaceholder" value="0"/>
</dictionary> </dictionary>
</binding> </binding>
</connections> </connections>
@ -1585,7 +1582,7 @@ Gw
<slider horizontalHuggingPriority="750" id="1612" customClass="VolumeSlider"> <slider horizontalHuggingPriority="750" id="1612" customClass="VolumeSlider">
<rect key="frame" x="43" y="39" width="15" height="120"/> <rect key="frame" x="43" y="39" width="15" height="120"/>
<autoresizingMask key="autoresizingMask"/> <autoresizingMask key="autoresizingMask"/>
<sliderCell key="cell" controlSize="small" continuous="YES" alignment="left" maxValue="100" doubleValue="100" tickMarkPosition="left" sliderType="linear" id="1613"> <sliderCell key="cell" controlSize="small" continuous="YES" alignment="left" maxValue="100" doubleValue="100" tickMarkPosition="right" sliderType="linear" id="1613">
<font key="font" metaFont="smallSystem"/> <font key="font" metaFont="smallSystem"/>
</sliderCell> </sliderCell>
<connections> <connections>
@ -1642,7 +1639,7 @@ Gw
<customObject id="2434" customClass="FeedbackController"/> <customObject id="2434" customClass="FeedbackController"/>
</objects> </objects>
<resources> <resources>
<image name="F80A8C12-27F0-4575-9C0A-CE9017032213" width="17" height="17"> <image name="D965DE51-1F62-4638-9E46-CD8ACABC7612" width="17" height="17">
<mutableData key="keyedArchiveRepresentation"> <mutableData key="keyedArchiveRepresentation">
YnBsaXN0MDDUAQIDBAUGRkdYJHZlcnNpb25YJG9iamVjdHNZJGFyY2hpdmVyVCR0b3ASAAGGoK8QDwcI YnBsaXN0MDDUAQIDBAUGRkdYJHZlcnNpb25YJG9iamVjdHNZJGFyY2hpdmVyVCR0b3ASAAGGoK8QDwcI
ExQZHh8qKyw0NzpAQ1UkbnVsbNUJCgsMDQ4PEBESVk5TU2l6ZVYkY2xhc3NcTlNJbWFnZUZsYWdzVk5T ExQZHh8qKyw0NzpAQ1UkbnVsbNUJCgsMDQ4PEBESVk5TU2l6ZVYkY2xhc3NcTlNJbWFnZUZsYWdzVk5T