Bug 1296531 - Don't wait for TracksAvailableCallback if tracks are already available. r=jesup
authorAndreas Pehrson <pehrsons@gmail.com>
Fri, 24 Feb 2017 14:34:25 +0100
changeset 383050 d84ded64c0bb1b6ad1ab1313e060c035bdf36771
parent 383049 55682948b181377b5e77a554baf063757b3ccaa9
child 383051 dae100b2958413ee671e8ca3dfea5331fa9c469e
push id32582
push userkwierso@gmail.com
push dateWed, 27 Sep 2017 00:11:27 +0000
treeherdermozilla-central@70158e4e215d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjesup
bugs1296531
milestone58.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 1296531 - Don't wait for TracksAvailableCallback if tracks are already available. r=jesup MozReview-Commit-ID: JQMyhhxaLLq
dom/media/MediaRecorder.cpp
--- a/dom/media/MediaRecorder.cpp
+++ b/dom/media/MediaRecorder.cpp
@@ -474,34 +474,38 @@ public:
   {
     LOG(LogLevel::Debug, ("Session.Start %p", this));
     MOZ_ASSERT(NS_IsMainThread());
 
     DOMMediaStream* domStream = mRecorder->Stream();
     if (domStream) {
       // The callback reports back when tracks are available and can be
       // attached to MediaEncoder. This allows `recorder.start()` before any tracks are available.
-      // We have supported this historically and have mochitests assuming this.
+      // We have supported this historically and have mochitests assuming this behavior.
       TracksAvailableCallback* tracksAvailableCallback = new TracksAvailableCallback(this);
       domStream->OnTracksAvailable(tracksAvailableCallback);
-    } else if (mRecorder->mAudioNode) {
+      return;
+    }
+
+    if (mRecorder->mAudioNode) {
       // Check that we may access the audio node's content.
       if (!AudioNodePrincipalSubsumes()) {
         LOG(LogLevel::Warning, ("Session.Start AudioNode principal check failed"));
         DoSessionEndTask(NS_ERROR_DOM_SECURITY_ERR);
         return;
       }
 
       TrackRate trackRate = mRecorder->mAudioNode->Context()->Graph()->GraphRate();
 
       // Web Audio node has only audio.
       InitEncoder(ContainerWriter::CREATE_AUDIO_TRACK, trackRate);
-    } else {
-      MOZ_ASSERT(false, "Unknown source");
+      return;
     }
+
+    MOZ_ASSERT(false, "Unknown source");
   }
 
   void Stop()
   {
     LOG(LogLevel::Debug, ("Session.Stop %p", this));
     MOZ_ASSERT(NS_IsMainThread());
     mStopIssued = true;