Bug 1276852 - Assert AudioStream::Start() is called when mState is INITIALIZED. r=kinetik.
MozReview-Commit-ID: DeGSEpSWYSM
--- a/dom/media/AudioStream.cpp
+++ b/dom/media/AudioStream.cpp
@@ -396,26 +396,20 @@ AudioStream::SetVolume(double aVolume)
NS_WARNING("Could not change volume on cubeb stream.");
}
}
void
AudioStream::Start()
{
MonitorAutoLock mon(mMonitor);
- if (mState == INITIALIZED) {
- // DataCallback might be called before InvokeCubeb returns
- // if cubeb_stream_start() succeeds. mState must be set to STARTED
- // beforehand.
- mState = STARTED;
- if (InvokeCubeb(cubeb_stream_start) != CUBEB_OK) {
- mState = ERRORED;
- }
- LOG("started, state %s", mState == STARTED ? "STARTED" : "ERRORED");
- }
+ MOZ_ASSERT(mState == INITIALIZED);
+ auto r = InvokeCubeb(cubeb_stream_start);
+ mState = r == CUBEB_OK ? STARTED : ERRORED;
+ LOG("started, state %s", mState == STARTED ? "STARTED" : "ERRORED");
}
void
AudioStream::Pause()
{
MonitorAutoLock mon(mMonitor);
if (mState == ERRORED) {