Bug 1169125 - Part 2: Use UniquePtr for scoped delete of yuv data in MediaPipeline. r=bwc
authorAndreas Pehrson <pehrsons@gmail.com>
Tue, 09 Jun 2015 13:31:34 +0800
changeset 267917 c3af3b1cf582abc0e171e4f87a3d0cff79f79b1a
parent 267916 92b2503d2ee77536a31d7a264e04bf14e5c01f82
child 267918 7f6477aa22705018bd534f98049e49a1f064f35c
push id8157
push userjlund@mozilla.com
push dateMon, 29 Jun 2015 20:36:23 +0000
treeherdermozilla-aurora@d480e05bd276 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbwc
bugs1169125
milestone41.0a1
Bug 1169125 - Part 2: Use UniquePtr for scoped delete of yuv data in MediaPipeline. r=bwc
media/webrtc/signaling/src/mediapipeline/MediaPipeline.cpp
--- a/media/webrtc/signaling/src/mediapipeline/MediaPipeline.cpp
+++ b/media/webrtc/signaling/src/mediapipeline/MediaPipeline.cpp
@@ -1171,19 +1171,20 @@ void MediaPipelineTransmit::PipelineList
       return;
     }
 
     gfx::IntSize size = img->GetSize();
     int half_width = (size.width + 1) >> 1;
     int half_height = (size.height + 1) >> 1;
     int c_size = half_width * half_height;
     int buffer_size = YSIZE(size.width, size.height) + 2 * c_size;
-    uint8* yuv = (uint8*) malloc(buffer_size); // fallible
-    if (!yuv)
+    UniquePtr<uint8[]> yuv_scoped(new (fallible) uint8[buffer_size]);
+    if (!yuv_scoped)
       return;
+    uint8* yuv = yuv_scoped.get();
 
     {
       DataSourceSurface::ScopedMap map(data, DataSourceSurface::READ);
       if (!map.IsMapped()) {
         MOZ_MTLOG(ML_ERROR, "Reading DataSourceSurface failed");
         return;
       }
 
@@ -1214,17 +1215,16 @@ void MediaPipelineTransmit::PipelineList
           return;
       }
       if (rv != 0) {
         MOZ_MTLOG(ML_ERROR, "RGB to I420 conversion failed");
         return;
       }
     }
     conduit->SendVideoFrame(yuv, buffer_size, size.width, size.height, mozilla::kVideoI420, 0);
-    free(yuv);
   }
 }
 #endif
 
 nsresult MediaPipelineReceiveAudio::Init() {
   ASSERT_ON_THREAD(main_thread_);
   MOZ_MTLOG(ML_DEBUG, __FUNCTION__);