mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-23 06:26:23 +00:00
Original commit message from CVS: * configure.ac: * docs/random/ensonic/media-device-daemon.txt: * tests/examples/controller/.cvsignore: * tests/examples/controller/Makefile.am: * tests/examples/controller/audio-example.c: (main): * tests/examples/helloworld/.cvsignore: * tests/examples/helloworld/Makefile.am: * tests/examples/helloworld/helloworld.c: (event_loop), (main): * tests/examples/launch/.cvsignore: * tests/examples/launch/Makefile.am: * tests/examples/launch/mp3parselaunch.c: (event_loop), (main): * tests/examples/metadata/.cvsignore: * tests/examples/metadata/Makefile.am: * tests/examples/metadata/read-metadata.c: (message_loop), (make_pipeline), (print_tag), (main): * tests/examples/queue/.cvsignore: * tests/examples/queue/Makefile.am: * tests/examples/queue/queue.c: (event_loop), (main): * tests/examples/typefind/.cvsignore: * tests/examples/typefind/Makefile.am: * tests/examples/typefind/typefind.c: (type_found), (event_loop), (main): * tests/examples/xml/.cvsignore: * tests/examples/xml/Makefile.am: * tests/examples/xml/createxml.c: (object_saved), (main): * tests/examples/xml/runxml.c: (xml_loaded), (event_loop), (main): * tests/old/examples/Makefile.am: * tests/old/examples/TODO: * tests/old/examples/controller/.cvsignore: * tests/old/examples/controller/Makefile.am: * tests/old/examples/controller/audio-example.c: * tests/old/examples/helloworld/.cvsignore: * tests/old/examples/helloworld/Makefile.am: * tests/old/examples/helloworld/helloworld.c: * tests/old/examples/launch/.cvsignore: * tests/old/examples/launch/Makefile.am: * tests/old/examples/launch/mp3parselaunch.c: * tests/old/examples/launch/mp3play: * tests/old/examples/manual/Makefile.am: * tests/old/examples/metadata/Makefile.am: * tests/old/examples/metadata/read-metadata.c: * tests/old/examples/queue/.cvsignore: * tests/old/examples/queue/Makefile.am: * tests/old/examples/queue/queue.c: * tests/old/examples/typefind/.cvsignore: * tests/old/examples/typefind/Makefile.am: * tests/old/examples/typefind/typefind.c: * tests/old/examples/xml/.cvsignore: * tests/old/examples/xml/Makefile.am: * tests/old/examples/xml/createxml.c: * tests/old/examples/xml/runxml.c: applied some simple fixing to some examples re-enabled the working examples
78 lines
2.3 KiB
C
78 lines
2.3 KiB
C
/*
|
|
* audio-example.c
|
|
*
|
|
* Build a pipeline with testaudiosource->alsasink
|
|
* and sweep frequency and volume
|
|
*
|
|
*/
|
|
|
|
#include <gst/gst.h>
|
|
#include <gst/controller/gstcontroller.h>
|
|
|
|
gint
|
|
main (gint argc, gchar ** argv)
|
|
{
|
|
gint res = 1;
|
|
GstElement *src, *sink;
|
|
GstElement *bin;
|
|
GstController *ctrl;
|
|
GstClock *clock;
|
|
GstClockID clock_id;
|
|
GstClockReturn wait_ret;
|
|
GValue vol = { 0, };
|
|
|
|
gst_init (&argc, &argv);
|
|
gst_controller_init (&argc, &argv);
|
|
|
|
// build pipeline
|
|
bin = gst_pipeline_new ("pipeline");
|
|
clock = gst_pipeline_get_clock (GST_PIPELINE (bin));
|
|
src = gst_element_factory_make ("audiotestsrc", "gen_audio");
|
|
sink = gst_element_factory_make ("alsasink", "play_audio");
|
|
gst_bin_add_many (GST_BIN (bin), src, sink, NULL);
|
|
if (!gst_element_link (src, sink)) {
|
|
GST_WARNING ("can't link elements");
|
|
goto Error;
|
|
}
|
|
// add a controller to the source
|
|
if (!(ctrl = gst_controller_new (G_OBJECT (src), "freq", "volume", NULL))) {
|
|
GST_WARNING ("can't control source element");
|
|
goto Error;
|
|
}
|
|
// set interpolation
|
|
gst_controller_set_interpolation_mode (ctrl, "volume",
|
|
GST_INTERPOLATE_LINEAR);
|
|
gst_controller_set_interpolation_mode (ctrl, "freq", GST_INTERPOLATE_LINEAR);
|
|
|
|
// set control values
|
|
g_value_init (&vol, G_TYPE_DOUBLE);
|
|
g_value_set_double (&vol, 0.0);
|
|
gst_controller_set (ctrl, "volume", 0 * GST_SECOND, &vol);
|
|
g_value_set_double (&vol, 1.0);
|
|
gst_controller_set (ctrl, "volume", 5 * GST_SECOND, &vol);
|
|
g_value_set_double (&vol, 440.0);
|
|
gst_controller_set (ctrl, "freq", 0 * GST_SECOND, &vol);
|
|
g_value_set_double (&vol, 3520.0);
|
|
gst_controller_set (ctrl, "freq", 3 * GST_SECOND, &vol);
|
|
g_value_set_double (&vol, 880.0);
|
|
gst_controller_set (ctrl, "freq", 6 * GST_SECOND, &vol);
|
|
|
|
clock_id =
|
|
gst_clock_new_single_shot_id (clock,
|
|
gst_clock_get_time (clock) + (7 * GST_SECOND));
|
|
|
|
// run for 7 seconds
|
|
if (gst_element_set_state (bin, GST_STATE_PLAYING)) {
|
|
if ((wait_ret = gst_clock_id_wait (clock_id, NULL)) != GST_CLOCK_OK) {
|
|
GST_WARNING ("clock_id_wait returned: %d", wait_ret);
|
|
}
|
|
gst_element_set_state (bin, GST_STATE_NULL);
|
|
}
|
|
// cleanup
|
|
g_object_unref (G_OBJECT (ctrl));
|
|
g_object_unref (G_OBJECT (clock));
|
|
g_object_unref (G_OBJECT (bin));
|
|
res = 0;
|
|
Error:
|
|
return (res);
|
|
}
|