Bug 1496281 - do not create audio stream if audio has ended. r=jya
☠☠ backed out by 7571ffba8492 ☠ ☠
authoralwu <alwu@mozilla.com>
Fri, 12 Oct 2018 20:43:22 +0000
changeset 499385 10dc6af46fbf04a72b7940a3b715c87f9f32cee6
parent 499384 74d5645c1fc68035f61d31cc93ccbe727fcb16fa
child 499386 67560e4bba2ccb548cafe53958eb9eb4e8033d5a
push id1864
push userffxbld-merge
push dateMon, 03 Dec 2018 15:51:40 +0000
treeherdermozilla-release@f040763d99ad [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjya
bugs1496281
milestone64.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 1496281 - do not create audio stream if audio has ended. r=jya We should not init the audio steam when the audio queue is marked as finished. Differential Revision: https://phabricator.services.mozilla.com/D8031
dom/media/mediasink/AudioSink.cpp
--- a/dom/media/mediasink/AudioSink.cpp
+++ b/dom/media/mediasink/AudioSink.cpp
@@ -71,16 +71,20 @@ AudioSink::~AudioSink()
 {
 }
 
 nsresult
 AudioSink::Init(const PlaybackParams& aParams, RefPtr<GenericPromise>& aEndPromise)
 {
   MOZ_ASSERT(mOwnerThread->IsCurrentThreadIn());
 
+  if (mAudioQueue.IsFinished()) {
+    return GenericPromise::CreateAndResolve(true, __func__);
+  }
+
   mAudioQueueListener = mAudioQueue.PushEvent().Connect(
     mOwnerThread, this, &AudioSink::OnAudioPushed);
   mAudioQueueFinishListener = mAudioQueue.FinishEvent().Connect(
     mOwnerThread, this, &AudioSink::NotifyAudioNeeded);
   mProcessedQueueListener = mProcessedQueue.PopEvent().Connect(
     mOwnerThread, this, &AudioSink::OnAudioPopped);
 
   // To ensure at least one audio packet will be popped from AudioQueue and
@@ -126,19 +130,19 @@ AudioSink::HasUnplayedFrames()
          (mAudioStream && mAudioStream->GetPositionInFrames() + 1 < total);
 }
 
 void
 AudioSink::Shutdown()
 {
   MOZ_ASSERT(mOwnerThread->IsCurrentThreadIn());
 
-  mAudioQueueListener.Disconnect();
-  mAudioQueueFinishListener.Disconnect();
-  mProcessedQueueListener.Disconnect();
+  mAudioQueueListener.DisconnectIfExists();
+  mAudioQueueFinishListener.DisconnectIfExists();
+  mProcessedQueueListener.DisconnectIfExists();
 
   if (mAudioStream) {
     mAudioStream->Shutdown();
     mAudioStream = nullptr;
   }
   mProcessedQueue.Reset();
   mProcessedQueue.Finish();
   mEndPromise.ResolveIfExists(true, __func__);