Bug 1514016 - Make MediaRecorder::Pause and MediaRecorder::Resume idempotent. r=jib, a=RyanVM
authorAndreas Pehrson <apehrson@mozilla.com>
Mon, 14 Jan 2019 18:32:56 +0000
changeset 509508 f8fa8bc2b93f37a5543c54771ca941ff8d5f953d
parent 509507 e74775e3a7417ae8c796cdb049d87d49805163b8
child 509509 662ea26b9f3465970dab5b0b210072076ede090e
push id1905
push userffxbld-merge
push dateMon, 21 Jan 2019 12:33:13 +0000
treeherdermozilla-release@c2fca1944d8c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjib, RyanVM
bugs1514016
milestone65.0
Bug 1514016 - Make MediaRecorder::Pause and MediaRecorder::Resume idempotent. r=jib, a=RyanVM Differential Revision: https://phabricator.services.mozilla.com/D15910
dom/media/MediaRecorder.cpp
--- a/dom/media/MediaRecorder.cpp
+++ b/dom/media/MediaRecorder.cpp
@@ -1340,16 +1340,20 @@ void MediaRecorder::Stop(ErrorResult& aR
 
 void MediaRecorder::Pause(ErrorResult& aResult) {
   LOG(LogLevel::Debug, ("MediaRecorder.Pause %p", this));
   if (mState == RecordingState::Inactive) {
     aResult.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
     return;
   }
 
+  if (mState == RecordingState::Paused) {
+    return;
+  }
+
   MOZ_ASSERT(mSessions.Length() > 0);
   nsresult rv = mSessions.LastElement()->Pause();
   if (NS_FAILED(rv)) {
     NotifyError(rv);
     return;
   }
 
   mState = RecordingState::Paused;
@@ -1357,16 +1361,20 @@ void MediaRecorder::Pause(ErrorResult& a
 
 void MediaRecorder::Resume(ErrorResult& aResult) {
   LOG(LogLevel::Debug, ("MediaRecorder.Resume %p", this));
   if (mState == RecordingState::Inactive) {
     aResult.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
     return;
   }
 
+  if (mState == RecordingState::Recording) {
+    return;
+  }
+
   MOZ_ASSERT(mSessions.Length() > 0);
   nsresult rv = mSessions.LastElement()->Resume();
   if (NS_FAILED(rv)) {
     NotifyError(rv);
     return;
   }
 
   mState = RecordingState::Recording;