From d63532883848c1e1fe1a5d96fa3c196036585ca5 Mon Sep 17 00:00:00 2001 From: Alex Chronopoulos Date: Tue, 12 Jul 2016 16:53:58 +0200 Subject: [PATCH] Bug 1286041 - Assert audio callback is not called in initialized state. r=jwwang --- dom/media/AudioStream.cpp | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/dom/media/AudioStream.cpp b/dom/media/AudioStream.cpp index 9ed2c593c30d..9aa0f969c074 100644 --- a/dom/media/AudioStream.cpp +++ b/dom/media/AudioStream.cpp @@ -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(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