Bug 1079621 - Return error instead of asserting. r=kinetik, a=lmandel
authorJean-Yves Avenard <jyavenard@mozilla.com>
Tue, 14 Oct 2014 12:49:32 +1100
changeset 225718 9be2b1620955
parent 225717 c3fa7201e034
child 225719 742beda04394
push id3989
push userryanvm@gmail.com
push date2014-10-17 01:41 +0000
treeherdermozilla-beta@9be2b1620955 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskinetik, lmandel
bugs1079621
milestone34.0
Bug 1079621 - Return error instead of asserting. r=kinetik, a=lmandel From c2a87a986f6d0ed699ab0fbf5687d8aa5fea8ff0 Mon Sep 17 00:00:00 2001 NS_ASSERTION is debug-only, and fails silently in continuous integration. Better to return an error here, since failure could result in a crash later.
content/media/fmp4/apple/AppleVTDecoder.cpp
--- a/content/media/fmp4/apple/AppleVTDecoder.cpp
+++ b/content/media/fmp4/apple/AppleVTDecoder.cpp
@@ -375,26 +375,35 @@ AppleVTDecoder::SubmitFrame(mp4_demuxer:
                                          ,aSample->data
                                          ,aSample->size
                                          ,kCFAllocatorNull // Block allocator.
                                          ,NULL // Block source.
                                          ,0    // Data offset.
                                          ,aSample->size
                                          ,false
                                          ,block.receive());
-  NS_ASSERTION(rv == noErr, "Couldn't create CMBlockBuffer");
+  if (rv != noErr) {
+    NS_ERROR("Couldn't create CMBlockBuffer");
+    return NS_ERROR_FAILURE;
+  }
   CMSampleTimingInfo timestamp = TimingInfoFromSample(aSample);
   rv = CMSampleBufferCreate(NULL, block, true, 0, 0, mFormat, 1, 1, &timestamp, 0, NULL, sample.receive());
-  NS_ASSERTION(rv == noErr, "Couldn't create CMSampleBuffer");
+  if (rv != noErr) {
+    NS_ERROR("Couldn't create CMSampleBuffer");
+    return NS_ERROR_FAILURE;
+  }
   rv = VTDecompressionSessionDecodeFrame(mSession,
                                          sample,
                                          0,
                                          new FrameRef(aSample),
                                          &flags);
-  NS_ASSERTION(rv == noErr, "Couldn't pass frame to decoder");
+  if (rv != noErr) {
+     NS_ERROR("Couldn't pass frame to decoder");
+     return NS_ERROR_FAILURE;
+  }
 
   // Ask for more data.
   if (mTaskQueue->IsEmpty()) {
     LOG("AppleVTDecoder task queue empty; requesting more data");
     mCallback->InputExhausted();
   }
 
   return NS_OK;