mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-04-07 08:39:54 +00:00
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
This commit is contained in:
parent
dbf12ab760
commit
8cd65c3250
1 changed files with 14 additions and 9 deletions
|
@ -152,18 +152,23 @@ gst_core_media_buffer_wrap_block_buffer (GstBuffer * buf,
|
|||
{
|
||||
OSStatus status;
|
||||
gchar *data = NULL;
|
||||
UInt32 size;
|
||||
size_t offset = 0, length_at_offset, total_length;
|
||||
|
||||
status = CMBlockBufferGetDataPointer (block_buf, 0, 0, 0, &data);
|
||||
if (status != noErr) {
|
||||
return FALSE;
|
||||
}
|
||||
/* 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;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue