From f99201f54db942e91a500b441d64539a2226fb50 Mon Sep 17 00:00:00 2001 From: Thong Nguyen Date: Sun, 16 Feb 2014 17:07:10 +0000 Subject: [PATCH] Explicitly wakeup playback thread if a delayed seek was queued --- StreamingKit/StreamingKit/STKAudioPlayer.m | 32 ++++++++++++++++++---- 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/StreamingKit/StreamingKit/STKAudioPlayer.m b/StreamingKit/StreamingKit/STKAudioPlayer.m index 09c9a46..091e9d0 100644 --- a/StreamingKit/StreamingKit/STKAudioPlayer.m +++ b/StreamingKit/StreamingKit/STKAudioPlayer.m @@ -977,6 +977,11 @@ static void AudioFileStreamPacketsProc(void* clientData, UInt32 numberBytes, UIn double retval = entry->seekTime + (entry->framesPlayed / canonicalAudioStreamBasicDescription.mSampleRate); OSSpinLockUnlock(&entry->spinLock); + if (retval == 0) + { + NSLog(@""); + } + return retval; } @@ -2291,17 +2296,24 @@ OSStatus AudioConverterCallback(AudioConverterRef inAudioConverter, UInt32* ioNu { return; } - - if ((seekToTimeWasRequested && [currentlyPlayingEntry calculatedBitRate] > 0.0) || disposeWasRequested) - { - return; - } + + if (disposeWasRequested) + { + return; + } if (audioConverterRef == nil) { return; } + if ((seekToTimeWasRequested && [currentlyPlayingEntry calculatedBitRate] > 0.0)) + { + [self wakeupPlaybackThread]; + + return; + } + discontinuous = NO; OSStatus status; @@ -2358,7 +2370,6 @@ OSStatus AudioConverterCallback(AudioConverterRef inAudioConverter, UInt32* ioNu } if (disposeWasRequested - || (seekToTimeWasRequested && [currentlyPlayingEntry calculatedBitRate] > 0.0) || self.internalState == STKAudioPlayerInternalStateStopped || self.internalState == STKAudioPlayerInternalStateDisposed || self.internalState == STKAudioPlayerInternalStatePendingNext) @@ -2367,6 +2378,15 @@ OSStatus AudioConverterCallback(AudioConverterRef inAudioConverter, UInt32* ioNu return; } + + if (seekToTimeWasRequested && [currentlyPlayingEntry calculatedBitRate] > 0.0) + { + pthread_mutex_unlock(&playerMutex); + + [self wakeupPlaybackThread]; + + return; + } waiting = YES;