Bug 1400537 - P1. Don't assume that the PDM will properly report an error. r?alwu draft
authorJean-Yves Avenard <jyavenard@mozilla.com>
Sun, 17 Sep 2017 18:01:37 +0200
changeset 666069 f62d02d732d6aec3278d65ed00003f3804131176
parent 666061 a4c8ad11eab79ea9358bec9f3f9aa414bcdb9162
child 666070 5769635fa4fc9f639170f6f56da4556e2b930620
push id80264
push userbmo:jyavenard@mozilla.com
push dateSun, 17 Sep 2017 16:07:26 +0000
reviewersalwu
bugs1400537
milestone57.0a1
Bug 1400537 - P1. Don't assume that the PDM will properly report an error. r?alwu Only the Windows H264 decoder supports CreateDecoderParam::mError, all the other PDM leave the value untouched. As such, it can't be assumed that in case of failure, the mError attribute will be set. MozReview-Commit-ID: GWHGP6Wv3fl
dom/media/platforms/wrappers/H264Converter.cpp
--- a/dom/media/platforms/wrappers/H264Converter.cpp
+++ b/dom/media/platforms/wrappers/H264Converter.cpp
@@ -262,34 +262,38 @@ H264Converter::CreateDecoder(const Video
       return MediaResult(NS_ERROR_DOM_MEDIA_FATAL_ERR,
                          RESULT_DETAIL("No support for YUV444 format."));
     }
   } else {
     return MediaResult(NS_ERROR_DOM_MEDIA_FATAL_ERR,
                        RESULT_DETAIL("Invalid SPS NAL."));
   }
 
+  MediaResult error = NS_OK;
   mDecoder = mPDM->CreateVideoDecoder({
     aConfig,
     mTaskQueue,
     aDiagnostics,
     mImageContainer,
     mKnowsCompositor,
     mGMPCrashHelper,
     mType,
     mOnWaitingForKeyEvent,
     mDecoderOptions,
-    &mLastError
+    &error
   });
 
   if (!mDecoder) {
-    MOZ_ASSERT(NS_FAILED(mLastError));
-    return MediaResult(mLastError.Code(),
-                       RESULT_DETAIL("Unable to create H264 decoder, reason = %s.",
-                                     mLastError.Description().get()));
+    if (NS_FAILED(error)) {
+      // The decoder supports CreateDecoderParam::mError, returns the value.
+      return error;
+    } else {
+      return MediaResult(NS_ERROR_DOM_MEDIA_FATAL_ERR,
+                         RESULT_DETAIL("Unable to create H264 decoder"));
+    }
   }
 
   mNeedKeyframe = true;
 
   return NS_OK;
 }
 
 MediaResult