Bug 1169125 - Part 2: Use UniquePtr for scoped delete of yuv data in MediaPipeline. r=bwc

This commit is contained in:
Andreas Pehrson 2015-06-09 13:31:34 +08:00
parent 4d0d1b1a47
commit 61cd5b21d6

View File

@ -1176,9 +1176,10 @@ void MediaPipelineTransmit::PipelineListener::ProcessVideoChunk(
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);
@ -1219,7 +1220,6 @@ void MediaPipelineTransmit::PipelineListener::ProcessVideoChunk(
}
}
conduit->SendVideoFrame(yuv, buffer_size, size.width, size.height, mozilla::kVideoI420, 0);
free(yuv);
}
}
#endif