Created a new internal state - AudioPlayerInternalStateRebuffering, it's mostly cosmetic so users of Audjustable are informed when playback pauses because the buffers have dried up

This commit is contained in:
Atli Thorbjornsson 2013-04-08 10:49:47 +00:00
parent 7abcc78b1e
commit 45e6edb28e
2 changed files with 14 additions and 2 deletions

View File

@ -49,8 +49,9 @@ typedef enum
AudioPlayerInternalStatePlaying = (1 << 1) | AudioPlayerInternalStateRunning,
AudioPlayerInternalStateStartingThread = (1 << 2) | AudioPlayerInternalStateRunning,
AudioPlayerInternalStateWaitingForData = (1 << 3) | AudioPlayerInternalStateRunning,
AudioPlayerInternalStateWaitingForQueueToStart = (1 << 5) | AudioPlayerInternalStateRunning,
AudioPlayerInternalStatePaused = (1 << 6) | AudioPlayerInternalStateRunning,
AudioPlayerInternalStateWaitingForQueueToStart = (1 << 4) | AudioPlayerInternalStateRunning,
AudioPlayerInternalStatePaused = (1 << 5) | AudioPlayerInternalStateRunning,
AudioPlayerInternalStateRebuffering = (1 << 6) | AudioPlayerInternalStateRunning,
AudioPlayerInternalStateStopping = (1 << 7),
AudioPlayerInternalStateStopped = (1 << 8),
AudioPlayerInternalStateDisposed = (1 << 9),

View File

@ -338,6 +338,7 @@ static void AudioQueueIsRunningCallbackProc(void* userData, AudioQueueRef audioQ
case AudioPlayerInternalStateWaitingForData:
case AudioPlayerInternalStateWaitingForQueueToStart:
case AudioPlayerInternalStatePlaying:
case AudioPlayerInternalStateRebuffering:
newState = AudioPlayerStatePlaying;
break;
case AudioPlayerInternalStateStopping:
@ -872,6 +873,11 @@ static void AudioQueueIsRunningCallbackProc(void* userData, AudioQueueRef audioQ
signal = YES;
}
if (!audioQueueFlushing && [self progress] > 4.0 && numberOfBuffersUsed == 0 ) {
self.internalState = AudioPlayerInternalStateRebuffering;
}
if (!audioQueueFlushing)
{
if (entry != nil)
@ -1018,6 +1024,11 @@ static void AudioQueueIsRunningCallbackProc(void* userData, AudioQueueRef audioQ
}
}
if (self.internalState == AudioPlayerInternalStateRebuffering && numberOfBuffersUsed >= AudioPlayerBuffersNeededToStart) {
self.internalState =AudioPlayerInternalStatePlaying;
}
if (++fillBufferIndex >= audioQueueBufferCount)
{
fillBufferIndex = 0;