From 7aae2bcb6bd39dabf9a7107d200cf2492a8d5a47 Mon Sep 17 00:00:00 2001 From: Thong Nguyen Date: Sun, 16 Feb 2014 16:50:12 +0000 Subject: [PATCH] Allow queueing of a seek request for a file before it has loaded --- StreamingKit/StreamingKit/STKAudioPlayer.m | 11 ++++++++--- StreamingKit/StreamingKit/STKHTTPDataSource.m | 4 ++-- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/StreamingKit/StreamingKit/STKAudioPlayer.m b/StreamingKit/StreamingKit/STKAudioPlayer.m index a3f1661..17f6c17 100644 --- a/StreamingKit/StreamingKit/STKAudioPlayer.m +++ b/StreamingKit/StreamingKit/STKAudioPlayer.m @@ -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) diff --git a/StreamingKit/StreamingKit/STKHTTPDataSource.m b/StreamingKit/StreamingKit/STKHTTPDataSource.m index cdc0142..367d7ac 100644 --- a/StreamingKit/StreamingKit/STKHTTPDataSource.m +++ b/StreamingKit/StreamingKit/STKHTTPDataSource.m @@ -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;