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
@ -154,18 +154,24 @@ 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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++) {
|
for (i = 0; i < buffer->n_planes; i++) {
|
||||||
if (!gst_buffer_find_memory (gstbuffer, meta->offsets[i],
|
if (!gst_buffer_find_memory (gstbuffer, meta->offsets[i],
|
||||||
GST_AUDIO_BUFFER_PLANE_SIZE (buffer), &idx, &length, &skip))
|
GST_AUDIO_BUFFER_PLANE_SIZE (buffer), &idx, &length, &skip))
|
||||||
goto no_memory;
|
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user