mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-06-07 07:58:51 +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;
|
buffer->map_infos = buffer->priv_map_infos_arr;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < buffer->n_planes; i++) {
|
if (buffer->n_samples == 0) {
|
||||||
if (!gst_buffer_find_memory (gstbuffer, meta->offsets[i],
|
memset (buffer->map_infos, 0,
|
||||||
GST_AUDIO_BUFFER_PLANE_SIZE (buffer), &idx, &length, &skip))
|
buffer->n_planes * sizeof (buffer->map_infos[0]));
|
||||||
goto no_memory;
|
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],
|
if (!gst_buffer_map_range (gstbuffer, idx, length,
|
||||||
flags))
|
&buffer->map_infos[i], flags))
|
||||||
goto cannot_map;
|
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