Bug 1344661 - capture input sample for CheckForSPSChange(). r=jya
authorAlastor Wu <alwu@mozilla.com>
Mon, 06 Mar 2017 18:16:04 +0800
changeset 346089 741f09f1b7f019567728e07cf75476b142225b61
parent 346088 940c4595cfeb766e3b25e8f6a0d8a9eaacac5aec
child 346090 010f66117cc5a9c651478148afce9f4499379186
push id31459
push usercbook@mozilla.com
push dateTue, 07 Mar 2017 14:05:14 +0000
treeherdermozilla-central@1fb56ba248d5 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjya
bugs1344661
milestone54.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 1344661 - capture input sample for CheckForSPSChange(). r=jya When the SPS changed, we save the input sample in |mPendingSample|, and then call CreateDecoderAndInit(mPendingSample) after calling shutdown(). However, the |mPendingSample| has been clear in shutdown(), so actually we send the nullptr to CreateDecoderAndInit(). MozReview-Commit-ID: JTRVdKxyEy6
dom/media/platforms/wrappers/H264Converter.cpp
--- a/dom/media/platforms/wrappers/H264Converter.cpp
+++ b/dom/media/platforms/wrappers/H264Converter.cpp
@@ -313,35 +313,34 @@ H264Converter::CheckForSPSChange(MediaRa
   RefPtr<MediaByteBuffer> extra_data =
     mp4_demuxer::AnnexB::ExtractExtraData(aSample);
   if (!mp4_demuxer::AnnexB::HasSPS(extra_data)
       || mp4_demuxer::AnnexB::CompareExtraData(extra_data,
                                                mCurrentConfig.mExtraData)) {
         return NS_OK;
       }
 
-  mPendingSample = aSample;
+  RefPtr<MediaRawData> sample = aSample;
 
   if (CanRecycleDecoder()) {
     // Do not recreate the decoder, reuse it.
     UpdateConfigFromExtraData(extra_data);
     // Ideally we would want to drain the decoder instead of flushing it.
     // However the draining operation requires calling Drain and looping several
     // times which isn't possible from within the H264Converter. So instead we
     // flush the decoder. In practice, this is a no-op as SPS change will only
     // be used with MSE. And with MSE, the MediaFormatReader would have drained
     // the decoder already.
     RefPtr<H264Converter> self = this;
     mDecoder->Flush()
       ->Then(AbstractThread::GetCurrent()->AsTaskQueue(),
              __func__,
-             [self, this]() {
+             [self, sample, this]() {
                mFlushRequest.Complete();
-               DecodeFirstSample(mPendingSample);
-               mPendingSample = nullptr;
+               DecodeFirstSample(sample);
              },
              [self, this](const MediaResult& aError) {
                mFlushRequest.Complete();
                mDecodePromise.Reject(aError, __func__);
              })
       ->Track(mFlushRequest);
     mNeedKeyframe = true;
     // This is not really initializing the decoder, but it will do as it
@@ -350,27 +349,26 @@ H264Converter::CheckForSPSChange(MediaRa
   }
 
   // The SPS has changed, signal to flush the current decoder and create a
   // new one.
   RefPtr<H264Converter> self = this;
   mDecoder->Flush()
     ->Then(AbstractThread::GetCurrent()->AsTaskQueue(),
            __func__,
-           [self, this]() {
+           [self, sample, this]() {
              mFlushRequest.Complete();
              mShutdownPromise = Shutdown();
              mShutdownPromise
                ->Then(AbstractThread::GetCurrent()->AsTaskQueue(),
                       __func__,
-                      [self, this]() {
+                      [self, sample, this]() {
                         mShutdownRequest.Complete();
                         mShutdownPromise = nullptr;
                         mNeedAVCC.reset();
-                        RefPtr<MediaRawData> sample = mPendingSample.forget();
                         nsresult rv = CreateDecoderAndInit(sample);
                         if (rv == NS_ERROR_DOM_MEDIA_INITIALIZING_DECODER) {
                           // All good so far, will continue later.
                           return;
                         }
                         MOZ_ASSERT(NS_FAILED(rv));
                         mDecodePromise.Reject(rv, __func__);
                         return;