Fix a race condition with opening files externally through file associations or the 'open' terminal command.

CQTexperiment
Chris Moeller 2016-05-07 22:41:28 -07:00
parent a1bf797f56
commit e531f288b2
1 changed files with 11 additions and 2 deletions

View File

@ -159,10 +159,18 @@ NSDictionary * makeRGInfo(PlaylistEntry *pe)
if (pe == nil)
return;
#if 0
// Race here, but the worst that could happen is we re-read the data
if ([pe metadataLoaded] != YES) {
if ([pe metadataLoaded] != YES) {
[pe performSelectorOnMainThread:@selector(setMetadata:) withObject:[playlistLoader readEntryInfo:pe] waitUntilDone:YES];
}
#else
// Racing with this version is less likely to jam up the main thread
if ([pe metadataLoaded] != YES) {
NSArray * entries = [NSArray arrayWithObject:pe];
[playlistLoader loadInfoForEntries:entries];
}
#endif
[audioPlayer play:[pe URL] withUserInfo:pe withRGInfo:makeRGInfo(pe) startPaused:paused];
}
@ -479,7 +487,8 @@ NSDictionary * makeRGInfo(PlaylistEntry *pe)
{
pe = [playlistController getNextEntry:curEntry];
if (pe && [pe metadataLoaded] != YES) {
[pe performSelectorOnMainThread:@selector(setMetadata:) withObject:[playlistLoader readEntryInfo:pe] waitUntilDone:YES];
NSArray * entries = [NSArray arrayWithObject:pe];
[playlistLoader loadInfoForEntries:entries];
}
}