Skip to content

Commit

Permalink
Correctly handle enqueued decoders that aren't starting from the firs…
Browse files Browse the repository at this point in the history
…t frame
  • Loading branch information
sbooth committed Jun 28, 2015
1 parent afb36e0 commit 85dda73
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion Player/AudioPlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ class SFB::Audio::Player::DecoderStateData

mDecoder = std::move(decoder);

mFramesRendered.store(mDecoder->GetCurrentFrame());

// NB: The decoder may return an estimate of the total frames
mTotalFrames = mDecoder->GetTotalFrames();
}
Expand Down Expand Up @@ -1497,7 +1499,7 @@ bool SFB::Audio::Player::ProvideAudio(AudioBufferList *bufferList, UInt32 frameC
SInt64 decoderFramesRemaining = (-1 == decoderState->mTotalFrames ? framesRead : decoderState->mTotalFrames - decoderState->mFramesRendered);
SInt64 framesFromThisDecoder = std::min(decoderFramesRemaining, (SInt64)framesRead);

if(0 == decoderState->mFramesRendered && !(eDecoderStateDataFlagRenderingStarted & decoderState->mFlags.load())) {
if(!(eDecoderStateDataFlagRenderingStarted & decoderState->mFlags.load())) {
// Call the rendering started block
if(mDecoderEventBlocks[2])
mDecoderEventBlocks[2](*decoderState->mDecoder);
Expand Down

0 comments on commit 85dda73

Please sign in to comment.