Commit 98afc401 authored by Avi Drissman's avatar Avi Drissman Committed by Chromium LUCI CQ

Fix leaks

CF-style frameworks use the CF naming conventions, and
calls named "Create" create objects whose lifetimes need
to be managed.

Bug: none
Change-Id: I56a57f93627a9fcb874f9f90d1c1d637e1172664
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2626517
Commit-Queue: Avi Drissman <avi@chromium.org>
Auto-Submit: Avi Drissman <avi@chromium.org>
Reviewed-by: default avatarMarkus Handell <handellm@google.com>
Cr-Commit-Position: refs/heads/master@{#843576}
parent baa9a37e
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include <tuple> #include <tuple>
#include "base/logging.h" #include "base/logging.h"
#include "base/mac/scoped_cftyperef.h"
#include "base/test/scoped_feature_list.h" #include "base/test/scoped_feature_list.h"
#include "build/build_config.h" #include "build/build_config.h"
#include "media/capture/video/mac/test/pixel_buffer_test_utils_mac.h" #include "media/capture/video/mac/test/pixel_buffer_test_utils_mac.h"
...@@ -296,9 +297,9 @@ base::ScopedCFTypeRef<CMSampleBufferRef> CreateSampleBuffer( ...@@ -296,9 +297,9 @@ base::ScopedCFTypeRef<CMSampleBufferRef> CreateSampleBuffer(
} }
// Wrap the pixel buffer in a sample buffer. // Wrap the pixel buffer in a sample buffer.
CMFormatDescriptionRef format_description; base::ScopedCFTypeRef<CMFormatDescriptionRef> format_description;
OSStatus status = CMVideoFormatDescriptionCreateForImageBuffer( OSStatus status = CMVideoFormatDescriptionCreateForImageBuffer(
nil, pixel_buffer, &format_description); nil, pixel_buffer, format_description.InitializeInto());
DCHECK(status == noErr); DCHECK(status == noErr);
// Dummy information to make CMSampleBufferCreateForImageBuffer() happy. // Dummy information to make CMSampleBufferCreateForImageBuffer() happy.
...@@ -321,16 +322,24 @@ base::ScopedCFTypeRef<CMSampleBufferRef> CreateMjpegSampleBuffer( ...@@ -321,16 +322,24 @@ base::ScopedCFTypeRef<CMSampleBufferRef> CreateMjpegSampleBuffer(
size_t mjpeg_data_size, size_t mjpeg_data_size,
size_t width, size_t width,
size_t height) { size_t height) {
CMBlockBufferRef data_buffer; CMBlockBufferCustomBlockSource source = {0};
source.FreeBlock = [](void* refcon, void* doomedMemoryBlock,
size_t sizeInBytes) {
// Do nothing. The data to be released is not dynamically allocated in this
// test code.
};
base::ScopedCFTypeRef<CMBlockBufferRef> data_buffer;
OSStatus status = CMBlockBufferCreateWithMemoryBlock( OSStatus status = CMBlockBufferCreateWithMemoryBlock(
nil, const_cast<void*>(static_cast<const void*>(mjpeg_data)), nil, const_cast<void*>(static_cast<const void*>(mjpeg_data)),
mjpeg_data_size, nil, nil, 0, mjpeg_data_size, 0, &data_buffer); mjpeg_data_size, nil, &source, 0, mjpeg_data_size, 0,
data_buffer.InitializeInto());
DCHECK(status == noErr); DCHECK(status == noErr);
CMFormatDescriptionRef format_description; base::ScopedCFTypeRef<CMFormatDescriptionRef> format_description;
status = status = CMVideoFormatDescriptionCreate(nil, kCMVideoCodecType_JPEG_OpenDML,
CMVideoFormatDescriptionCreate(nil, kCMVideoCodecType_JPEG_OpenDML, width, width, height, nil,
height, nil, &format_description); format_description.InitializeInto());
DCHECK(status == noErr); DCHECK(status == noErr);
// Dummy information to make CMSampleBufferCreateReady() happy. // Dummy information to make CMSampleBufferCreateReady() happy.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment