audio: Move fill_silence into audio_format_info

With the function named gst_audio_format_fill_silence it would get
associated to the GstAudioFormat type in .gir which is incorrect and
confusing. See [1] for the discussion sparking this change.

https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/630#note_694795

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-base/-/merge_requests/940>
This commit is contained in:
Marijn Suijten 2020-11-24 20:54:49 +01:00
parent c1f91ba004
commit 3ec795f613
11 changed files with 38 additions and 14 deletions

View file

@ -478,7 +478,7 @@ do_unpack (AudioChain * chain, gpointer user_data)
}
} else {
for (i = 0; i < chain->blocks; i++) {
gst_audio_format_fill_silence (chain->finfo, tmp[i],
gst_audio_format_info_fill_silence (chain->finfo, tmp[i],
num_samples * chain->inc);
}
}
@ -1102,7 +1102,7 @@ converter_passthrough (GstAudioConverter * convert,
}
} else {
for (i = 0; i < chain->blocks; i++)
gst_audio_format_fill_silence (convert->in.finfo, out[i], samples);
gst_audio_format_info_fill_silence (convert->in.finfo, out[i], samples);
}
return TRUE;
}
@ -1248,7 +1248,7 @@ converter_endian (GstAudioConverter * convert,
convert->swap_endian (out[i], in[i], samples);
} else {
for (i = 0; i < chain->blocks; i++)
gst_audio_format_fill_silence (convert->in.finfo, out[i], samples);
gst_audio_format_info_fill_silence (convert->in.finfo, out[i], samples);
}
return TRUE;
}

View file

@ -459,10 +459,30 @@ gst_audio_format_get_info (GstAudioFormat format)
* @length: the length to fill
*
* Fill @length bytes in @dest with silence samples for @info.
*
* Deprecated: 1.20: Use gst_audio_format_info_fill_silence() instead.
*/
void
gst_audio_format_fill_silence (const GstAudioFormatInfo * info,
gpointer dest, gsize length)
{
gst_audio_format_info_fill_silence (info, dest, length);
}
/**
* gst_audio_format_info_fill_silence:
* @info: a #GstAudioFormatInfo
* @dest: (array length=length) (element-type guint8): a destination
* to fill
* @length: the length to fill
*
* Fill @length bytes in @dest with silence samples for @info.
*
* Since: 1.20
*/
void
gst_audio_format_info_fill_silence (const GstAudioFormatInfo * info,
gpointer dest, gsize length)
{
guint8 *dptr = dest;

View file

@ -286,8 +286,11 @@ const GstAudioFormatInfo *
gst_audio_format_get_info (GstAudioFormat format) G_GNUC_CONST;
GST_AUDIO_API
void gst_audio_format_fill_silence (const GstAudioFormatInfo *info,
gpointer dest, gsize length);
void gst_audio_format_info_fill_silence (const GstAudioFormatInfo *info,
gpointer dest, gsize length);
GST_AUDIO_API G_DEPRECATED_FOR(gst_audio_format_info_fill_silence)
void gst_audio_format_fill_silence (const GstAudioFormatInfo *info,
gpointer dest, gsize length);
/**
* GST_AUDIO_RATE_RANGE:

View file

@ -1870,7 +1870,8 @@ gst_audio_aggregator_create_output_buffer (GstAudioAggregator * aagg,
gst_object_unref (allocator);
gst_buffer_map (outbuf, &outmap, GST_MAP_WRITE);
gst_audio_format_fill_silence (srcpad->info.finfo, outmap.data, outmap.size);
gst_audio_format_info_fill_silence (srcpad->info.finfo, outmap.data,
outmap.size);
gst_buffer_unmap (outbuf, &outmap);
return outbuf;

View file

@ -656,7 +656,7 @@ gst_audio_ring_buffer_acquire (GstAudioRingBuffer * buf,
buf->empty_seg = g_malloc (segsize);
if (buf->spec.type == GST_AUDIO_RING_BUFFER_FORMAT_TYPE_RAW) {
gst_audio_format_fill_silence (buf->spec.info.finfo, buf->empty_seg,
gst_audio_format_info_fill_silence (buf->spec.info.finfo, buf->empty_seg,
segsize);
} else {
/* FIXME, non-raw formats get 0 as the empty sample */

View file

@ -414,7 +414,7 @@ gst_audio_sink_ring_buffer_acquire (GstAudioRingBuffer * buf,
buf->memory = g_malloc (buf->size);
if (buf->spec.type == GST_AUDIO_RING_BUFFER_FORMAT_TYPE_RAW) {
gst_audio_format_fill_silence (buf->spec.info.finfo, buf->memory,
gst_audio_format_info_fill_silence (buf->spec.info.finfo, buf->memory,
buf->size);
} else {
/* FIXME, non-raw formats get 0 as the empty sample */

View file

@ -384,7 +384,7 @@ gst_audio_src_ring_buffer_acquire (GstAudioRingBuffer * buf,
buf->size = spec->segtotal * spec->segsize;
buf->memory = g_malloc (buf->size);
if (buf->spec.type == GST_AUDIO_RING_BUFFER_FORMAT_TYPE_RAW) {
gst_audio_format_fill_silence (buf->spec.info.finfo, buf->memory,
gst_audio_format_info_fill_silence (buf->spec.info.finfo, buf->memory,
buf->size);
} else {
/* FIXME, non-raw formats get 0 as the empty sample */

View file

@ -1424,7 +1424,7 @@ gst_adder_collected (GstCollectPads * pads, gpointer user_data)
/* Means we had all pads muted, create some silence */
outbuf = gst_buffer_new_allocate (NULL, outsize, NULL);
gst_buffer_map (outbuf, &map, GST_MAP_WRITE);
gst_audio_format_fill_silence (adder->info.finfo, map.data, outsize);
gst_audio_format_info_fill_silence (adder->info.finfo, map.data, outsize);
gst_buffer_unmap (outbuf, &map);
GST_BUFFER_FLAG_SET (outbuf, GST_BUFFER_FLAG_GAP);
} else {

View file

@ -849,8 +849,8 @@ gst_audio_convert_transform (GstBaseTransform * base, GstBuffer * inbuf,
/* Create silence buffer */
gint i;
for (i = 0; i < dstabuf.n_planes; i++) {
gst_audio_format_fill_silence (this->out_info.finfo, dstabuf.planes[i],
GST_AUDIO_BUFFER_PLANE_SIZE (&dstabuf));
gst_audio_format_info_fill_silence (this->out_info.finfo,
dstabuf.planes[i], GST_AUDIO_BUFFER_PLANE_SIZE (&dstabuf));
}
}
ret = GST_FLOW_OK;

View file

@ -559,7 +559,7 @@ gst_audio_rate_chain (GstPad * pad, GstObject * parent, GstBuffer * buf)
fill = gst_buffer_new_and_alloc (fillsize);
gst_buffer_map (fill, &fillmap, GST_MAP_WRITE);
gst_audio_format_fill_silence (audiorate->info.finfo, fillmap.data,
gst_audio_format_info_fill_silence (audiorate->info.finfo, fillmap.data,
fillmap.size);
gst_buffer_unmap (fill, &fillmap);

View file

@ -926,7 +926,7 @@ GST_START_TEST (test_fill_silence)
for (f = GST_AUDIO_FORMAT_S8; f < GST_AUDIO_FORMAT_F64; f++) {
gst_audio_info_set_format (&info, f, 48000, 1, NULL);
gst_audio_format_fill_silence (info.finfo, test_silence,
gst_audio_format_info_fill_silence (info.finfo, test_silence,
GST_AUDIO_INFO_BPF (&info) * 4);
for (i = 0; i < 4; i++)