mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 12:11:13 +00:00
audio-buffer: Don't fail to map buffers with zero samples
Instead initialize the map infos, etc to NULL like gst_buffer_map() would be doing on a zero-sized buffer. This fixes a crash in audioresample if the first output buffer would contain zero samples.
This commit is contained in:
parent
4960f385cf
commit
89f613abf5
1 changed files with 14 additions and 8 deletions
|
@ -154,16 +154,22 @@ gst_audio_buffer_map (GstAudioBuffer * buffer, const GstAudioInfo * info,
|
|||
buffer->map_infos = buffer->priv_map_infos_arr;
|
||||
}
|
||||
|
||||
for (i = 0; i < buffer->n_planes; i++) {
|
||||
if (!gst_buffer_find_memory (gstbuffer, meta->offsets[i],
|
||||
GST_AUDIO_BUFFER_PLANE_SIZE (buffer), &idx, &length, &skip))
|
||||
goto no_memory;
|
||||
if (buffer->n_samples == 0) {
|
||||
memset (buffer->map_infos, 0,
|
||||
buffer->n_planes * sizeof (buffer->map_infos[0]));
|
||||
memset (buffer->planes, 0, buffer->n_planes * sizeof (buffer->planes[0]));
|
||||
} else {
|
||||
for (i = 0; i < buffer->n_planes; i++) {
|
||||
if (!gst_buffer_find_memory (gstbuffer, meta->offsets[i],
|
||||
GST_AUDIO_BUFFER_PLANE_SIZE (buffer), &idx, &length, &skip))
|
||||
goto no_memory;
|
||||
|
||||
if (!gst_buffer_map_range (gstbuffer, idx, length, &buffer->map_infos[i],
|
||||
flags))
|
||||
goto cannot_map;
|
||||
if (!gst_buffer_map_range (gstbuffer, idx, length,
|
||||
&buffer->map_infos[i], flags))
|
||||
goto cannot_map;
|
||||
|
||||
buffer->planes[i] = buffer->map_infos[i].data + skip;
|
||||
buffer->planes[i] = buffer->map_infos[i].data + skip;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue