Skip to content

Commit

Permalink
audio: Move fill_silence into audio_format_info
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
MarijnS95 committed Nov 25, 2020
1 parent c1f91ba commit 3ec795f
Show file tree
Hide file tree
Showing 11 changed files with 38 additions and 14 deletions.
6 changes: 3 additions & 3 deletions gst-libs/gst/audio/audio-converter.c
Expand Up @@ -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);
}
}
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
}
Expand Down
20 changes: 20 additions & 0 deletions gst-libs/gst/audio/audio-format.c
Expand Up @@ -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;

Expand Down
7 changes: 5 additions & 2 deletions gst-libs/gst/audio/audio-format.h
Expand Up @@ -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:
Expand Down
3 changes: 2 additions & 1 deletion gst-libs/gst/audio/gstaudioaggregator.c
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion gst-libs/gst/audio/gstaudioringbuffer.c
Expand Up @@ -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 */
Expand Down
2 changes: 1 addition & 1 deletion gst-libs/gst/audio/gstaudiosink.c
Expand Up @@ -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 */
Expand Down
2 changes: 1 addition & 1 deletion gst-libs/gst/audio/gstaudiosrc.c
Expand Up @@ -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 */
Expand Down
2 changes: 1 addition & 1 deletion gst/adder/gstadder.c
Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions gst/audioconvert/gstaudioconvert.c
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion gst/audiorate/gstaudiorate.c
Expand Up @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion tests/check/libs/audio.c
Expand Up @@ -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++)
Expand Down

0 comments on commit 3ec795f

Please sign in to comment.