Bug 1286041 - Assert audio callback is not called in initialized state. r=jwwang

This commit is contained in:
Alex Chronopoulos 2016-07-12 16:53:58 +02:00
parent ff133bd20d
commit d635328838

View File

@ -400,9 +400,12 @@ AudioStream::Start()
{
MonitorAutoLock mon(mMonitor);
MOZ_ASSERT(mState == INITIALIZED);
mState = STARTED;
auto r = InvokeCubeb(cubeb_stream_start);
mState = r == CUBEB_OK ? STARTED : ERRORED;
LOG("started, state %s", mState == STARTED ? "STARTED" : "ERRORED");
if (r != CUBEB_OK) {
mState = ERRORED;
}
LOG("started, state %s", mState == STARTED ? "STARTED" : mState == DRAINED ? "DRAINED" : "ERRORED");
}
void
@ -593,13 +596,7 @@ AudioStream::DataCallback(void* aBuffer, long aFrames)
auto writer = AudioBufferWriter(
reinterpret_cast<AudioDataValue*>(aBuffer), mOutChannels, aFrames);
// FIXME: cubeb_pulse sometimes calls us before cubeb_stream_start() is called.
// We don't want to consume audio data until Start() is called by the client.
if (mState == INITIALIZED) {
NS_WARNING("data callback fires before cubeb_stream_start() is called");
mAudioClock.UpdateFrameHistory(0, aFrames);
return writer.WriteZeros(aFrames);
}
MOZ_ASSERT(mState != INITIALIZED);
// NOTE: wasapi (others?) can call us back *after* stop()/Shutdown() (mState == SHUTDOWN)
// Bug 996162