Bug 1657246 - Properly stop the MockCubebStream after forcing an error in it. r=padenot
☠☠ backed out by 08d69cbea998 ☠ ☠
authorAndreas Pehrson <apehrson@mozilla.com>
Tue, 27 Oct 2020 14:37:35 +0000
changeset 554784 fbba0ed1f3e9b0c015e20bcb0166d8ec7be53df5
parent 554783 e7d0acdef9c3f01bf55c1eb91b7a431203f5a241
child 554785 9ee3d71303c6a71faee7d91bbb073fe3621bf297
push id37898
push userabutkovits@mozilla.com
push dateWed, 28 Oct 2020 09:24:21 +0000
treeherdermozilla-central@83bf4fd3b1fb [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspadenot
bugs1657246
milestone84.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1657246 - Properly stop the MockCubebStream after forcing an error in it. r=padenot Without this MockCubeb will call into this (destroyed) stream again once another stream exists. Differential Revision: https://phabricator.services.mozilla.com/D94565
dom/media/gtest/MockCubeb.cpp
--- a/dom/media/gtest/MockCubeb.cpp
+++ b/dom/media/gtest/MockCubeb.cpp
@@ -123,16 +123,22 @@ void MockCubebStream::Process10Ms() {
 
   if (outframes < nrFrames) {
     mStateCallback(stream, mUserPtr, CUBEB_STATE_DRAINED);
     mStreamStop = true;
     return;
   }
   if (mForceErrorState) {
     mForceErrorState = false;
+    // Let the audio thread (this thread!) run to completion before
+    // being released, by joining and releasing on main.
+    NS_DispatchBackgroundTask(NS_NewRunnableFunction(
+        __func__, [cubeb = reinterpret_cast<MockCubeb*>(context), this] {
+          cubeb->StopStream(this);
+        }));
     mStateCallback(stream, mUserPtr, CUBEB_STATE_ERROR);
     mErrorForcedEvent.Notify();
     mStreamStop = true;
     return;
   }
 }
 
 MockCubeb::MockCubeb() : ops(&mock_ops) {}