controller: port to API changes

This commit is contained in:
Stefan Sauer 2011-12-31 09:55:46 +01:00
parent b41d4544bf
commit 3b3de767c1

View file

@ -37,9 +37,8 @@ main (int argc, char **argv)
GstElement *pitch; GstElement *pitch;
GstElement *sink; GstElement *sink;
GstElement *pipeline; GstElement *pipeline;
GstController *ctl;
GstInterpolationControlSource *csource; GstInterpolationControlSource *csource;
GValue val = { 0, }; GstTimedValueControlSource *cs;
if (argc != 2) { if (argc != 2) {
g_printerr ("Usage: %s <audiosink>\n", argv[0]); g_printerr ("Usage: %s <audiosink>\n", argv[0]);
@ -68,46 +67,30 @@ main (int argc, char **argv)
gst_element_link_many (audiotestsrc, audioconvert1, pitch, audioconvert2, gst_element_link_many (audiotestsrc, audioconvert1, pitch, audioconvert2,
sink, NULL); sink, NULL);
if (!(ctl = gst_controller_new (G_OBJECT (pitch), "pitch", NULL))) { /* set up a controller */
g_print ("can't control pitch element\n");
return -1;
}
csource = gst_interpolation_control_source_new (); csource = gst_interpolation_control_source_new ();
g_object_set (csource, "mode", GST_INTERPOLATION_MODE_LINEAR, NULL); g_object_set (csource, "mode", GST_INTERPOLATION_MODE_LINEAR, NULL);
gst_controller_set_control_source (ctl, "pitch", gst_object_set_control_source (pitch, "pitch", GST_CONTROL_SOURCE (csource));
GST_CONTROL_SOURCE (csource)); cs = (GstTimedValueControlSource *) csource;
g_value_init (&val, G_TYPE_FLOAT);
for (i = 0; i < 100; ++i) { for (i = 0; i < 100; ++i) {
if (i % 2) if (i % 2)
g_value_set_float (&val, 0.5); gst_timed_value_control_source_set (cs, i * GST_SECOND, 0.5);
else else
g_value_set_float (&val, 1.5); gst_timed_value_control_source_set (cs, i * GST_SECOND, 1.5);
gst_timed_value_control_source_set ((GstTimedValueControlSource *) csource,
i * GST_SECOND, &val);
} }
g_value_unset (&val);
gst_element_set_state (pipeline, GST_STATE_PLAYING); gst_element_set_state (pipeline, GST_STATE_PLAYING);
g_print ("Running\n"); g_print ("Running\n");
g_main_loop_run (loop); g_main_loop_run (loop);
/* set up a controller */
/* clean up nicely */ /* clean up nicely */
gst_object_unref (csource);
g_print ("Returned, stopping playback\n"); g_print ("Returned, stopping playback\n");
gst_element_set_state (pipeline, GST_STATE_NULL); gst_element_set_state (pipeline, GST_STATE_NULL);
g_print ("Deleting pipeline\n"); g_print ("Deleting pipeline\n");
gst_object_unref (GST_OBJECT (pipeline)); gst_object_unref (GST_OBJECT (pipeline));
g_object_unref (csource);
g_object_unref (ctl);
return 0; return 0;
} }