controller: adapt to controller api changes

Don't use the convenience api for control sources.
This commit is contained in:
Stefan Sauer 2012-01-20 08:29:02 +01:00
parent ea9ef0ee63
commit 0e370d4902
3 changed files with 29 additions and 27 deletions

View file

@ -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));

View file

@ -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,

View file

@ -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 */