From 0b5b6ada8876d26e50364cf16e787b6ca428f263 Mon Sep 17 00:00:00 2001 From: Thong Nguyen Date: Mon, 27 Jan 2014 22:34:25 +0000 Subject: [PATCH] Return 0 duration and progress if stop was requested --- StreamingKit/StreamingKit/STKAudioPlayer.m | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/StreamingKit/StreamingKit/STKAudioPlayer.m b/StreamingKit/StreamingKit/STKAudioPlayer.m index 124a874..0d36eca 100644 --- a/StreamingKit/StreamingKit/STKAudioPlayer.m +++ b/StreamingKit/StreamingKit/STKAudioPlayer.m @@ -1030,7 +1030,7 @@ static void AudioQueueIsRunningCallbackProc(void* userData, AudioQueueRef audioQ framesPerPacket = currentlyReadingEntry->audioStreamBasicDescription.mFramesPerPacket; } - if (currentlyReadingEntry->processedPacketsCount * framesPerPacket < currentlyReadingEntry->audioStreamBasicDescription.mSampleRate * 15 * currentlyReadingEntry->audioStreamBasicDescription.mChannelsPerFrame) + if (currentlyReadingEntry->processedPacketsCount * framesPerPacket < currentlyReadingEntry->audioStreamBasicDescription.mSampleRate * 10 * currentlyReadingEntry->audioStreamBasicDescription.mChannelsPerFrame) { OSAtomicAdd32((int32_t)packetSize, ¤tlyReadingEntry->processedPacketsSizeTotal); OSAtomicIncrement32(¤tlyReadingEntry->processedPacketsCount); @@ -1885,6 +1885,11 @@ static void AudioQueueIsRunningCallbackProc(void* userData, AudioQueueRef audioQ return 0; } + if (self.internalState == AudioPlayerInternalStateStopped) + { + return 0; + } + OSSpinLockLock(¤tEntryReferencesLock); STKQueueEntry* entry = currentlyPlayingEntry; @@ -1917,6 +1922,11 @@ static void AudioQueueIsRunningCallbackProc(void* userData, AudioQueueRef audioQ return requestedSeekTime; } + if (self.internalState == AudioPlayerInternalStateStopped) + { + return 0; + } + if (newFileToPlay) { return 0; @@ -2842,8 +2852,6 @@ static void AudioQueueIsRunningCallbackProc(void* userData, AudioQueueRef audioQ currentlyReadingEntry.lastFrameIndex = self->framesQueued; currentlyReadingEntry.lastByteIndex = audioPacketsReadCount; - LOGINFO(([NSString stringWithFormat:@"eof2: %lld %lld %d", audioPacketsReadCount, audioPacketsPlayedCount, numberOfBuffersUsed])); - if (numberOfBuffersUsed == 0 && currentlyReadingEntry == currentlyPlayingEntry) { seekToTimeWasRequested = NO;