From 6050509b650b57489d33b24478bf8a9cc12d06f1 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Tue, 26 Jan 2016 17:16:52 +0100 Subject: [PATCH] audio-converter: improve _update_config Allow NULL config to keep the existing parameters. Fix the docs. --- gst-libs/gst/audio/audio-converter.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/gst-libs/gst/audio/audio-converter.c b/gst-libs/gst/audio/audio-converter.c index 5b0746c..cb6d6fe 100644 --- a/gst-libs/gst/audio/audio-converter.c +++ b/gst-libs/gst/audio/audio-converter.c @@ -292,13 +292,16 @@ copy_config (GQuark field_id, const GValue * value, gpointer user_data) * @convert: a #GstAudioConverter * @in_rate: input rate * @out_rate: output rate - * @config: (transfer full): a #GstStructure + * @config: (transfer full) (allow-none): a #GstStructure or %NULL * - * Set @config as extra configuration for @convert. + * Set @in_rate, @out_rate and @config as extra configuration for @convert. * * in_rate and @out_rate specify the new sample rates of input and output * formats. A value of 0 leaves the sample rate unchanged. * + * @config can be %NULL, in which case, the current configuration is not + * changed. + * * If the parameters in @config can not be set exactly, this function returns * %FALSE and will try to update as much state as possible. The new state can * then be retrieved and refined with gst_audio_converter_get_config(). @@ -306,14 +309,13 @@ copy_config (GQuark field_id, const GValue * value, gpointer user_data) * Look at the #GST_AUDIO_CONVERTER_OPT_* fields to check valid configuration * option and values. * - * Returns: %TRUE when @config could be set. + * Returns: %TRUE when the new parameters could be set */ gboolean gst_audio_converter_update_config (GstAudioConverter * convert, gint in_rate, gint out_rate, GstStructure * config) { g_return_val_if_fail (convert != NULL, FALSE); - g_return_val_if_fail (config != NULL, FALSE); g_return_val_if_fail ((in_rate == 0 && out_rate == 0) || convert->flags & GST_AUDIO_CONVERTER_FLAG_VARIABLE_RATE, FALSE); @@ -327,8 +329,10 @@ gst_audio_converter_update_config (GstAudioConverter * convert, convert->in.rate = in_rate; convert->out.rate = out_rate; - gst_structure_foreach (config, copy_config, convert); - gst_structure_free (config); + if (config) { + gst_structure_foreach (config, copy_config, convert); + gst_structure_free (config); + } return TRUE; } -- 2.7.4