Skip to content

Commit

Permalink
audioaggregator: Consider converting for equal audio formats
Browse files Browse the repository at this point in the history
The converter might have a non-passthrough mix-matrix. The converter
can determine whether it should pass through, so let it, then remove it
if it's indeed a passthrough.

FIXME: Not converting when we need to but the config is invalid (e.g.
because the mix-matrix is not the right size) produces garbage. An
invalid config should cause a GST_FLOW_NOT_NEGOTIATED.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-base/-/merge_requests/1070>
  • Loading branch information
heftig committed Mar 16, 2021
1 parent 43449d9 commit a379e0e
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions gst-libs/gst/audio/gstaudioaggregator.c
Expand Up @@ -200,23 +200,35 @@ gst_audio_aggregator_convert_pad_update_converter (GstAudioAggregatorConvertPad
* aaggcpad, GstAudioInfo * in_info, GstAudioInfo * out_info)
{
GstStructure *config = aaggcpad->priv->converter_config;
GstAudioConverter *converter;

if (!aaggcpad->priv->converter_config_changed)
return;

g_clear_pointer (&aaggcpad->priv->converter, gst_audio_converter_free);
aaggcpad->priv->converter_config_changed = FALSE;

if (gst_audio_info_is_equal (in_info, out_info) ||
in_info->finfo->format == GST_AUDIO_FORMAT_UNKNOWN) {
if (in_info->finfo->format == GST_AUDIO_FORMAT_UNKNOWN) {
/* If we haven't received caps yet, this pad should not have
* a buffer to convert anyway */
return;
}

aaggcpad->priv->converter =
converter =
gst_audio_converter_new (GST_AUDIO_CONVERTER_FLAG_NONE, in_info, out_info,
config ? gst_structure_copy (config) : NULL);

if (converter == NULL) {
/* FIXME: Not converting when we need to but the config is invalid (e.g.
* because the mix-matrix is not the right size) produces garbage. An
* invalid config should cause a GST_FLOW_NOT_NEGOTIATED. */
return;
}

if (!gst_audio_converter_is_passthrough (converter))
aaggcpad->priv->converter = converter;
else
gst_audio_converter_free (converter);
}

static void
Expand Down

0 comments on commit a379e0e

Please sign in to comment.