From 0e370d4902ac54393a78b103b8be9ddcb73afc8d Mon Sep 17 00:00:00 2001 From: Stefan Sauer Date: Fri, 20 Jan 2012 08:29:02 +0100 Subject: [PATCH] controller: adapt to controller api changes Don't use the convenience api for control sources. --- gst/volume/gstvolume.c | 36 +++++++++++++++++------------------- tests/check/elements/volume.c | 10 ++++++---- tests/icles/audio-trickplay.c | 10 ++++++---- 3 files changed, 29 insertions(+), 27 deletions(-) diff --git a/gst/volume/gstvolume.c b/gst/volume/gstvolume.c index c19991e..97b7fb0 100644 --- a/gst/volume/gstvolume.c +++ b/gst/volume/gstvolume.c @@ -801,7 +801,7 @@ volume_transform_ip (GstBaseTransform * base, GstBuffer * outbuf) GstVolume *self = GST_VOLUME (base); guint8 *data; gsize size; - GstControlSource *mute_csource, *volume_csource; + GstControlBinding *mute_cb, *volume_cb; if (G_UNLIKELY (!self->negotiated)) goto not_negotiated; @@ -813,10 +813,10 @@ volume_transform_ip (GstBaseTransform * base, GstBuffer * outbuf) data = gst_buffer_map (outbuf, &size, NULL, GST_MAP_READWRITE); - mute_csource = gst_object_get_control_source (GST_OBJECT (self), "mute"); - volume_csource = gst_object_get_control_source (GST_OBJECT (self), "volume"); + mute_cb = gst_object_get_control_binding (GST_OBJECT (self), "mute"); + volume_cb = gst_object_get_control_binding (GST_OBJECT (self), "volume"); - if (mute_csource || (volume_csource && !self->current_mute)) { + if (mute_cb || (volume_cb && !self->current_mute)) { gint rate = GST_AUDIO_INFO_RATE (&filter->info); gint width = GST_AUDIO_FORMAT_INFO_WIDTH (filter->info.finfo) / 8; gint channels = GST_AUDIO_INFO_CHANNELS (&filter->info); @@ -827,7 +827,7 @@ volume_transform_ip (GstBaseTransform * base, GstBuffer * outbuf) ts = gst_segment_to_stream_time (&base->segment, GST_FORMAT_TIME, ts); - if (self->mutes_count < nsamples && mute_csource) { + if (self->mutes_count < nsamples && mute_cb) { self->mutes = g_realloc (self->mutes, sizeof (gboolean) * nsamples); self->mutes_count = nsamples; } @@ -837,13 +837,12 @@ volume_transform_ip (GstBaseTransform * base, GstBuffer * outbuf) self->volumes_count = nsamples; } - if (mute_csource) { - if (!gst_control_source_get_value_array (mute_csource, ts, interval, + if (mute_cb) { + if (!gst_control_binding_get_value_array (mute_cb, ts, interval, nsamples, (gpointer) self->mutes)) goto controller_failure; - gst_object_unref (mute_csource); - mute_csource = NULL; + gst_object_replace ((GstObject **) & mute_cb, NULL); use_mutes = TRUE; } else { g_free (self->mutes); @@ -851,13 +850,12 @@ volume_transform_ip (GstBaseTransform * base, GstBuffer * outbuf) self->mutes_count = 0; } - if (volume_csource) { - if (!gst_control_source_get_value_array (volume_csource, ts, interval, + if (volume_cb) { + if (!gst_control_binding_get_value_array (volume_cb, ts, interval, nsamples, (gpointer) self->volumes)) goto controller_failure; - gst_object_unref (volume_csource); - volume_csource = NULL; + gst_object_replace ((GstObject **) & volume_cb, NULL); } else { orc_memset_f64 (self->volumes, self->current_volume, nsamples); } @@ -869,8 +867,8 @@ volume_transform_ip (GstBaseTransform * base, GstBuffer * outbuf) self->process_controlled (self, data, self->volumes, channels, size); return GST_FLOW_OK; - } else if (volume_csource) { - gst_object_unref (volume_csource); + } else if (volume_cb) { + gst_object_unref (volume_cb); } if (self->current_volume == 0.0 || self->current_mute) { @@ -892,10 +890,10 @@ not_negotiated: } controller_failure: { - if (mute_csource) - gst_object_unref (mute_csource); - if (volume_csource) - gst_object_unref (volume_csource); + if (mute_cb) + gst_object_unref (mute_cb); + if (volume_cb) + gst_object_unref (volume_cb); GST_ELEMENT_ERROR (self, CORE, FAILED, ("Failed to get values from controller"), (NULL)); diff --git a/tests/check/elements/volume.c b/tests/check/elements/volume.c index cb44d55..00da31e 100644 --- a/tests/check/elements/volume.c +++ b/tests/check/elements/volume.c @@ -1730,8 +1730,9 @@ GST_START_TEST (test_controller_usability) /* this shouldn't crash, whether this mode is implemented or not */ csource = gst_interpolation_control_source_new (); g_object_set (csource, "mode", GST_INTERPOLATION_MODE_CUBIC, NULL); - gst_object_set_control_source (GST_OBJECT_CAST (volume), "volume", - GST_CONTROL_SOURCE (csource)); + gst_object_set_control_binding (GST_OBJECT_CAST (volume), + gst_control_binding_new (GST_OBJECT_CAST (volume), "volume", + GST_CONTROL_SOURCE (csource))); cs = (GstTimedValueControlSource *) csource; gst_timed_value_control_source_set (cs, 0 * GST_SECOND, 0.0); @@ -1759,8 +1760,9 @@ GST_START_TEST (test_controller_processing) csource = gst_interpolation_control_source_new (); g_object_set (csource, "mode", GST_INTERPOLATION_MODE_CUBIC, NULL); - gst_object_set_control_source (GST_OBJECT_CAST (volume), "volume", - GST_CONTROL_SOURCE (csource)); + gst_object_set_control_binding (GST_OBJECT_CAST (volume), + gst_control_binding_new (GST_OBJECT_CAST (volume), "volume", + GST_CONTROL_SOURCE (csource))); fail_unless (gst_element_set_state (volume, GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS, diff --git a/tests/icles/audio-trickplay.c b/tests/icles/audio-trickplay.c index acdb328..937928a 100644 --- a/tests/icles/audio-trickplay.c +++ b/tests/icles/audio-trickplay.c @@ -127,10 +127,12 @@ main (gint argc, gchar ** argv) csource1 = gst_interpolation_control_source_new (); csource2 = gst_interpolation_control_source_new (); - gst_object_set_control_source (GST_OBJECT (src), "volume", - GST_CONTROL_SOURCE (csource1)); - gst_object_set_control_source (GST_OBJECT (src), "freq", - GST_CONTROL_SOURCE (csource2)); + gst_object_set_control_binding (GST_OBJECT_CAST (src), + gst_control_binding_new (GST_OBJECT_CAST (src), "volume", + GST_CONTROL_SOURCE (csource1))); + gst_object_set_control_binding (GST_OBJECT_CAST (src), + gst_control_binding_new (GST_OBJECT_CAST (src), "freq", + GST_CONTROL_SOURCE (csource2))); /* Set interpolation mode */ -- 2.7.4