From 33acf7333481a43d915281c9f1898e40fb89f2bd Mon Sep 17 00:00:00 2001 From: Jochen Henneberg Date: Sun, 3 Nov 2019 10:25:55 +0000 Subject: [PATCH] audioconvert: Fixed changing mix-matrix at runtime Setting the property again after it had already been set ran g_value_unset() but did not initialize it again to g_value_copy() failed afterwards. Removed the unset as cleanup is done implicitely from g_value_copy(). Changing the mix-matrix property did not trigger reconfiguration of the caps, this has been added. If the matrix is set to an empty matrix, instead of copying this the matrix is simply disabled by setting mix_matrix_is_set (formerly mix_matrix_was_set) to FALSE so the mix-matrix is ignored from now on. --- gst/audioconvert/gstaudioconvert.c | 17 ++++++++--------- gst/audioconvert/gstaudioconvert.h | 2 +- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/gst/audioconvert/gstaudioconvert.c b/gst/audioconvert/gstaudioconvert.c index 2269e0a8dc..5af83cf6ac 100644 --- a/gst/audioconvert/gstaudioconvert.c +++ b/gst/audioconvert/gstaudioconvert.c @@ -328,7 +328,7 @@ remove_channels_from_structure (GstCapsFeatures * features, GstStructure * s, /* Only remove the channels and channel-mask for non-NONE layouts, * or if a mix matrix was manually specified */ - if (this->mix_matrix_was_set || + if (this->mix_matrix_is_set || !gst_structure_get (s, "channel-mask", GST_TYPE_BITMASK, &mask, NULL) || (mask != 0 || (gst_structure_get_int (s, "channels", &channels) && channels == 1))) { @@ -763,7 +763,7 @@ gst_audio_convert_set_caps (GstBaseTransform * base, GstCaps * incaps, GST_AUDIO_CONVERTER_OPT_NOISE_SHAPING_METHOD, GST_TYPE_AUDIO_NOISE_SHAPING_METHOD, this->ns, NULL); - if (this->mix_matrix_was_set) + if (this->mix_matrix_is_set) gst_structure_set_value (config, GST_AUDIO_CONVERTER_OPT_MIX_MATRIX, &this->mix_matrix); @@ -976,17 +976,16 @@ gst_audio_convert_set_property (GObject * object, guint prop_id, break; case PROP_MIX_MATRIX: if (!gst_value_array_get_size (value)) { - g_value_copy (value, &this->mix_matrix); - this->mix_matrix_was_set = TRUE; + this->mix_matrix_is_set = FALSE; } else { const GValue *first_row = gst_value_array_get_value (value, 0); if (gst_value_array_get_size (first_row)) { - if (gst_value_array_get_size (&this->mix_matrix)) - g_value_unset (&this->mix_matrix); - g_value_copy (value, &this->mix_matrix); - this->mix_matrix_was_set = TRUE; + this->mix_matrix_is_set = TRUE; + + /* issue a reconfigure upstream */ + gst_base_transform_reconfigure_sink (GST_BASE_TRANSFORM (this)); } else { g_warning ("Empty mix matrix's first row"); } @@ -1012,7 +1011,7 @@ gst_audio_convert_get_property (GObject * object, guint prop_id, g_value_set_enum (value, this->ns); break; case PROP_MIX_MATRIX: - if (this->mix_matrix_was_set) + if (this->mix_matrix_is_set) g_value_copy (&this->mix_matrix, value); break; default: diff --git a/gst/audioconvert/gstaudioconvert.h b/gst/audioconvert/gstaudioconvert.h index 3efbfe08aa..8befffd815 100644 --- a/gst/audioconvert/gstaudioconvert.h +++ b/gst/audioconvert/gstaudioconvert.h @@ -48,7 +48,7 @@ struct _GstAudioConvert GstAudioDitherMethod dither; GstAudioNoiseShapingMethod ns; GValue mix_matrix; - gboolean mix_matrix_was_set; + gboolean mix_matrix_is_set; GstAudioInfo in_info; GstAudioInfo out_info;