Bug 1303673 - Part 6: Provide further error details for the apple decoders. r=cpearce, a=gchang
authorJean-Yves Avenard <jyavenard@mozilla.com>
Tue, 20 Sep 2016 16:05:32 +1000
changeset 355723 0de15106f9b9a16b93e1bb532ec1cbad68f79112
parent 355722 8fdc4515793453c97253603bd7843888ef2c97e2
child 355724 01f9952a4a119079e29035c7745d3c9945c804b1
push id6570
push userraliiev@mozilla.com
push dateMon, 14 Nov 2016 12:26:13 +0000
treeherdermozilla-beta@f455459b2ae5 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerscpearce, gchang
bugs1303673
milestone51.0a2
Bug 1303673 - Part 6: Provide further error details for the apple decoders. r=cpearce, a=gchang MozReview-Commit-ID: 1A0k5BWAlWW
dom/media/platforms/apple/AppleATDecoder.cpp
dom/media/platforms/apple/AppleVTDecoder.cpp
--- a/dom/media/platforms/apple/AppleATDecoder.cpp
+++ b/dom/media/platforms/apple/AppleATDecoder.cpp
@@ -189,30 +189,31 @@ AppleATDecoder::SubmitSample(MediaRawDat
   if (mIsFlushing) {
     return;
   }
 
   nsresult rv = NS_OK;
   if (!mConverter) {
     rv = SetupDecoder(aSample);
     if (rv != NS_OK && rv != NS_ERROR_NOT_INITIALIZED) {
-      mCallback->Error(MediaResult(NS_ERROR_DOM_MEDIA_FATAL_ERR,
-                                        __func__));
+      mCallback->Error(
+        MediaResult(rv, RESULT_DETAIL("Unable to create decoder")));
       return;
     }
   }
 
   mQueuedSamples.AppendElement(aSample);
 
   if (rv == NS_OK) {
     for (size_t i = 0; i < mQueuedSamples.Length(); i++) {
       rv = DecodeSample(mQueuedSamples[i]);
       if (NS_FAILED(rv)) {
         mQueuedSamples.Clear();
-        mCallback->Error(MediaResult(rv, __func__));
+        mCallback->Error(MediaResult(
+          rv, RESULT_DETAIL("Unable to decode sample %lld", aSample->mTime)));
         return;
       }
     }
     mQueuedSamples.Clear();
   }
   mCallback->InputExhausted();
 }
 
--- a/dom/media/platforms/apple/AppleVTDecoder.cpp
+++ b/dom/media/platforms/apple/AppleVTDecoder.cpp
@@ -305,18 +305,20 @@ AppleVTDecoder::OutputFrame(CVPixelBuffe
     MOZ_ASSERT(planes == 2, "Likely not NV12 format and it must be.");
 
     VideoData::YCbCrBuffer buffer;
 
     // Lock the returned image data.
     CVReturn rv = CVPixelBufferLockBaseAddress(aImage, kCVPixelBufferLock_ReadOnly);
     if (rv != kCVReturnSuccess) {
       NS_ERROR("error locking pixel data");
-      mCallback->Error(MediaResult(NS_ERROR_OUT_OF_MEMORY, __func__));
-      return NS_ERROR_OUT_OF_MEMORY;
+      mCallback->Error(
+        MediaResult(NS_ERROR_DOM_MEDIA_DECODE_ERR,
+                    RESULT_DETAIL("CVPixelBufferLockBaseAddress:%x", rv)));
+      return NS_ERROR_DOM_MEDIA_DECODE_ERR;
     }
     // Y plane.
     buffer.mPlanes[0].mData =
       static_cast<uint8_t*>(CVPixelBufferGetBaseAddressOfPlane(aImage, 0));
     buffer.mPlanes[0].mStride = CVPixelBufferGetBytesPerRowOfPlane(aImage, 0);
     buffer.mPlanes[0].mWidth = width;
     buffer.mPlanes[0].mHeight = height;
     buffer.mPlanes[0].mOffset = 0;
@@ -441,38 +443,43 @@ AppleVTDecoder::DoDecode(MediaRawData* a
                                           kCFAllocatorNull, // Block allocator.
                                           NULL, // Block source.
                                           0,    // Data offset.
                                           aSample->Size(),
                                           false,
                                           block.receive());
   if (rv != noErr) {
     NS_ERROR("Couldn't create CMBlockBuffer");
-    mCallback->Error(MediaResult(NS_ERROR_OUT_OF_MEMORY, __func__));
+    mCallback->Error(
+      MediaResult(NS_ERROR_OUT_OF_MEMORY,
+                  RESULT_DETAIL("CMBlockBufferCreateWithMemoryBlock:%x", rv)));
     return MediaResult(NS_ERROR_OUT_OF_MEMORY, __func__);
   }
   CMSampleTimingInfo timestamp = TimingInfoFromSample(aSample);
   rv = CMSampleBufferCreate(kCFAllocatorDefault, block, true, 0, 0, mFormat, 1, 1, &timestamp, 0, NULL, sample.receive());
   if (rv != noErr) {
     NS_ERROR("Couldn't create CMSampleBuffer");
-    mCallback->Error(MediaResult(NS_ERROR_OUT_OF_MEMORY, __func__));
+    mCallback->Error(MediaResult(NS_ERROR_OUT_OF_MEMORY,
+                                 RESULT_DETAIL("CMSampleBufferCreate:%x", rv)));
     return MediaResult(NS_ERROR_OUT_OF_MEMORY, __func__);
   }
 
   VTDecodeFrameFlags decodeFlags =
     kVTDecodeFrame_EnableAsynchronousDecompression;
   rv = VTDecompressionSessionDecodeFrame(mSession,
                                          sample,
                                          decodeFlags,
                                          CreateAppleFrameRef(aSample),
                                          &infoFlags);
   if (rv != noErr && !(infoFlags & kVTDecodeInfo_FrameDropped)) {
     LOG("AppleVTDecoder: Error %d VTDecompressionSessionDecodeFrame", rv);
     NS_WARNING("Couldn't pass frame to decoder");
-    mCallback->Error(MediaResult(NS_ERROR_DOM_MEDIA_DECODE_ERR, __func__));
+    mCallback->Error(
+      MediaResult(NS_ERROR_DOM_MEDIA_DECODE_ERR,
+                  RESULT_DETAIL("VTDecompressionSessionDecodeFrame:%x", rv)));
     return NS_ERROR_DOM_MEDIA_DECODE_ERR;
   }
 
   return NS_OK;
 }
 
 nsresult
 AppleVTDecoder::InitializeSession()