Bug 693095 - Fix audio stream position estimation for remoted streams. Also resurrect audio thread wait removed in bug 669556 when using remoted audio streams. r=cpearce
This commit is contained in:
@@ -635,6 +635,29 @@ void nsBuiltinDecoderStateMachine::AudioLoop()
|
||||
NS_WARNING("Int overflow calculating audio end time");
|
||||
break;
|
||||
}
|
||||
|
||||
// The remoted audio stream does not block writes when the other end's buffers
|
||||
// are full, so this sleep is necessary to stop the audio thread spinning its
|
||||
// wheels. When bug 695612 is fixed, this block of code can be removed.
|
||||
#if defined(REMOTE_AUDIO)
|
||||
PRInt64 audioAhead = mAudioEndTime - GetMediaTime();
|
||||
if (audioAhead > AMPLE_AUDIO_USECS &&
|
||||
framesWritten > minWriteFrames)
|
||||
{
|
||||
// We've pushed enough audio onto the hardware that we've queued up a
|
||||
// significant amount ahead of the playback position. The decode
|
||||
// thread will be going to sleep, so we won't get any new audio
|
||||
// anyway, so sleep until we need to push to the hardware again.
|
||||
Wait(AMPLE_AUDIO_USECS / 2);
|
||||
// Kick the decode thread; since above we only do a NotifyAll when
|
||||
// we pop an audio chunk of the queue, the decoder won't wake up if
|
||||
// we've got no more decoded chunks to push to the hardware. We can
|
||||
// hit this condition if the last frame in the stream doesn't have
|
||||
// it's EOS flag set, and the decode thread sleeps just after decoding
|
||||
// that packet, but before realising there's no more packets.
|
||||
mon.NotifyAll();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
if (mReader->mAudioQueue.AtEndOfStream() &&
|
||||
|
||||
Reference in New Issue
Block a user