Bug 1538508 - P1. Reset mError upon success. r=bryce
authorJean-Yves Avenard <jyavenard@mozilla.com>
Wed, 27 Mar 2019 11:01:57 +0000
changeset 466324 ee7d1a2f8ebd21eed7ea2083f0cb23149763e118
parent 466323 da4c9acc07e119f7bbf6888e4729ccbc373f424f
child 466325 ea116addae50b8e65e75f4c875b9e583c1c74f34
push id35764
push useraciure@mozilla.com
push dateWed, 27 Mar 2019 16:35:35 +0000
treeherdermozilla-central@16f19322ec76 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbryce
bugs1538508
milestone68.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 1538508 - P1. Reset mError upon success. r=bryce Differential Revision: https://phabricator.services.mozilla.com/D24869
media/webrtc/signaling/src/media-conduit/WebrtcMediaDataDecoderCodec.cpp
--- a/media/webrtc/signaling/src/media-conduit/WebrtcMediaDataDecoderCodec.cpp
+++ b/media/webrtc/signaling/src/media-conduit/WebrtcMediaDataDecoderCodec.cpp
@@ -2,18 +2,18 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "WebrtcMediaDataDecoderCodec.h"
 #include "ImageContainer.h"
 #include "Layers.h"
 #include "PDMFactory.h"
 #include "VideoUtils.h"
+#include "mozilla/layers/ImageBridgeChild.h"
 #include "mozilla/media/MediaUtils.h"
-#include "mozilla/layers/ImageBridgeChild.h"
 #include "webrtc/rtc_base/keep_ref_until_done.h"
 
 namespace mozilla {
 
 WebrtcMediaDataDecoder::WebrtcMediaDataDecoder()
     : mThreadPool(GetMediaThreadPool(MediaThreadType::PLATFORM_DECODER)),
       mTaskQueue(new TaskQueue(do_AddRef(mThreadPool),
                                "WebrtcMediaDataDecoder::mTaskQueue")),
@@ -44,27 +44,31 @@ int32_t WebrtcMediaDataDecoder::InitDeco
   mTrackType = TrackInfo::kVideoTrack;
 
   mInfo = VideoInfo(aCodecSettings->width, aCodecSettings->height);
   mInfo.mMimeType = codec;
 
   RefPtr<layers::KnowsCompositor> knowsCompositor =
       layers::ImageBridgeChild::GetSingleton();
 
+  if (mDecoder) {
+    Release();
+  }
+
   mDecoder = mFactory->CreateDecoder(
       {mInfo, mTaskQueue,
        CreateDecoderParams::OptionSet(CreateDecoderParams::Option::LowLatency),
        mTrackType, mImageContainer, knowsCompositor});
 
   if (!mDecoder) {
     return WEBRTC_VIDEO_CODEC_ERROR;
   }
 
   media::Await(do_AddRef(mThreadPool), mDecoder->Init(),
-               [](TrackInfo::TrackType) {},
+               [&](TrackInfo::TrackType) { mError = NS_OK; },
                [&](const MediaResult& aError) { mError = aError; });
 
   return NS_SUCCEEDED(mError) ? WEBRTC_VIDEO_CODEC_OK
                               : WEBRTC_VIDEO_CODEC_ERROR;
 }
 
 int32_t WebrtcMediaDataDecoder::Decode(
     const webrtc::EncodedImage& aInputImage, bool aMissingFrames,
@@ -102,16 +106,17 @@ int32_t WebrtcMediaDataDecoder::Decode(
   compressedFrame->mTimecode =
       media::TimeUnit::FromMicroseconds(aRenderTimeMs * 1000);
   compressedFrame->mKeyframe =
       aInputImage._frameType == webrtc::FrameType::kVideoFrameKey;
   {
     media::Await(do_AddRef(mThreadPool), mDecoder->Decode(compressedFrame),
                  [&](const MediaDataDecoder::DecodedData& aResults) {
                    mResults = aResults;
+                   mError = NS_OK;
                  },
                  [&](const MediaResult& aError) { mError = aError; });
 
     for (auto& frame : mResults) {
       MOZ_ASSERT(frame->mType == MediaData::Type::VIDEO_DATA);
       RefPtr<VideoData> video = frame->As<VideoData>();
       MOZ_ASSERT(video);
       if (!video->mImage) {
@@ -139,16 +144,17 @@ int32_t WebrtcMediaDataDecoder::Register
 }
 
 int32_t WebrtcMediaDataDecoder::Release() {
   RefPtr<MediaDataDecoder> decoder = mDecoder.forget();
   decoder->Flush()->Then(mTaskQueue, __func__,
                          [decoder]() { decoder->Shutdown(); });
 
   mNeedKeyframe = true;
+  mError = NS_OK;
 
   return WEBRTC_VIDEO_CODEC_OK;
 }
 
 bool WebrtcMediaDataDecoder::OnTaskQueue() const {
   return OwnerThread()->IsCurrentThreadIn();
 }