Allow queueing of a seek request for a file before it has loaded

This commit is contained in:
Thong Nguyen 2014-02-16 16:50:12 +00:00
parent 5a8068b859
commit 7aae2bcb6b
2 changed files with 10 additions and 5 deletions

View File

@ -976,6 +976,11 @@ static void AudioFileStreamPacketsProc(void* clientData, UInt32 numberBytes, UIn
OSSpinLockLock(&entry->spinLock);
double retval = entry->seekTime + (entry->framesPlayed / canonicalAudioStreamBasicDescription.mSampleRate);
OSSpinLockUnlock(&entry->spinLock);
if (retval == 0)
{
NSLog(@"");
}
return retval;
}
@ -1325,7 +1330,7 @@ static void AudioFileStreamPacketsProc(void* clientData, UInt32 numberBytes, UIn
}
}
if (currentlyPlayingEntry && currentlyPlayingEntry->parsedHeader)
if (currentlyPlayingEntry && currentlyPlayingEntry->parsedHeader && [currentlyPlayingEntry calculatedBitRate] > 0.0)
{
int32_t originalSeekVersion;
BOOL originalSeekToTimeRequested;
@ -2292,7 +2297,7 @@ OSStatus AudioConverterCallback(AudioConverterRef inAudioConverter, UInt32* ioNu
return;
}
if (seekToTimeWasRequested || disposeWasRequested)
if ((seekToTimeWasRequested && [currentlyPlayingEntry calculatedBitRate] > 0.0) || disposeWasRequested)
{
return;
}
@ -2358,7 +2363,7 @@ OSStatus AudioConverterCallback(AudioConverterRef inAudioConverter, UInt32* ioNu
}
if (disposeWasRequested
|| seekToTimeWasRequested
|| (seekToTimeWasRequested && [currentlyPlayingEntry calculatedBitRate] > 0.0)
|| self.internalState == STKAudioPlayerInternalStateStopped
|| self.internalState == STKAudioPlayerInternalStateDisposed
|| self.internalState == STKAudioPlayerInternalStatePendingNext)

View File

@ -221,7 +221,7 @@
[self close];
eventsRunLoop = savedEventsRunLoop;
[self seekToOffset:self.position];
}
@ -232,7 +232,7 @@
[self close];
eventsRunLoop = savedEventsRunLoop;
NSAssert([NSRunLoop currentRunLoop] == eventsRunLoop, @"Seek called on wrong thread");
stream = 0;