diff options
author | Ilya Konstantinov <ilya.konstantinov@gmail.com> | 2015-04-27 15:02:59 +0300 |
---|---|---|
committer | Sebastian Dröge <sebastian@centricular.com> | 2015-06-25 10:33:54 +0200 |
commit | 8cd65c325093e8c951d8b39d403591871519f750 (patch) | |
tree | 4d35ab5d0c8154cf7c186108409af5fb1a957e51 /sys | |
parent | dbf12ab760c1a5c735617823fff0cc487439da1d (diff) | |
download | gstreamer-plugins-bad-8cd65c325093e8c951d8b39d403591871519f750.tar.gz |
applemedia: CMBlockBuffer can be non-contiguous
CMBlockBufferGetDataLength would return the entire data length, while
size of individual blocks can be smaller. Iterate over the block buffer
and add the individual (possibly non-contiguous) memory blocks.
https://bugzilla.gnome.org/show_bug.cgi?id=751071
Diffstat (limited to 'sys')
-rw-r--r-- | sys/applemedia/coremediabuffer.c | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/sys/applemedia/coremediabuffer.c b/sys/applemedia/coremediabuffer.c index 1070da526..87e4cc349 100644 --- a/sys/applemedia/coremediabuffer.c +++ b/sys/applemedia/coremediabuffer.c @@ -152,18 +152,23 @@ gst_core_media_buffer_wrap_block_buffer (GstBuffer * buf, { OSStatus status; gchar *data = NULL; - UInt32 size; - - status = CMBlockBufferGetDataPointer (block_buf, 0, 0, 0, &data); - if (status != noErr) { - return FALSE; - } + size_t offset = 0, length_at_offset, total_length; + + /* CMBlockBuffer can contain multiple non-continuous memory blocks */ + do { + status = + CMBlockBufferGetDataPointer (block_buf, offset, &length_at_offset, + &total_length, &data); + if (status != kCMBlockBufferNoErr) { + return FALSE; + } - size = CMBlockBufferGetDataLength (block_buf); + gst_buffer_append_memory (buf, + gst_memory_new_wrapped (GST_MEMORY_FLAG_NO_SHARE, data, + length_at_offset, 0, length_at_offset, NULL, NULL)); - gst_buffer_append_memory (buf, - gst_memory_new_wrapped (GST_MEMORY_FLAG_NO_SHARE, data, - size, 0, size, NULL, NULL)); + offset += length_at_offset; + } while (offset < total_length); return TRUE; } |