mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-27 02:30:35 +00:00
9f06376bab
Original commit message from CVS: * docs/design/part-events.txt: Small update. * gst/base/gstbasesink.c: (gst_base_sink_handle_object), (gst_base_sink_do_sync), (gst_base_sink_activate_push), (gst_base_sink_activate_pull): Some more comments. * gst/elements/gstfakesrc.c: (gst_fake_src_class_init), (gst_fake_src_create): Fix handoff marshall. * gst/elements/gstidentity.c: (gst_identity_class_init), (gst_identity_transform_ip): We're a real inplace element. * gst/gstbus.c: (gst_bus_post): Added some comments. * tests/lat.c: (fakesrc), (fakesink), (simple), (queue), (main): * tests/muxing/case1.c: (main): * tests/sched/dynamic-pipeline.c: (main): * tests/sched/interrupt1.c: (main): * tests/sched/interrupt2.c: (main): * tests/sched/interrupt3.c: (main): * tests/sched/runxml.c: (main): * tests/sched/sched-stress.c: (main): * tests/seeking/seeking1.c: (event_received), (main): * tests/threadstate/threadstate2.c: (bus_handler), (timeout_func), (main): * tests/threadstate/threadstate3.c: (main): * tests/threadstate/threadstate4.c: (main): * tests/threadstate/threadstate5.c: (main): Fix the tests.
90 lines
2.1 KiB
C
90 lines
2.1 KiB
C
#include <stdlib.h>
|
|
#include <gst/gst.h>
|
|
|
|
static GMainLoop *loop;
|
|
static gboolean EOS = FALSE;
|
|
|
|
/* this pipeline is:
|
|
* { filesrc ! mad ! osssink }
|
|
*/
|
|
|
|
static gboolean
|
|
bus_handler (GstBus * bus, GstMessage * message, gpointer data)
|
|
{
|
|
switch (GST_MESSAGE_TYPE (message)) {
|
|
case GST_MESSAGE_EOS:
|
|
g_print ("have eos, quitting\n");
|
|
EOS = TRUE;
|
|
if (g_main_loop_is_running (loop))
|
|
g_main_loop_quit (loop);
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
return TRUE;
|
|
}
|
|
|
|
static gboolean
|
|
timeout_func (GMainLoop * loop)
|
|
{
|
|
g_main_loop_quit (loop);
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
int
|
|
main (int argc, char *argv[])
|
|
{
|
|
GstElement *filesrc, *osssink;
|
|
GstElement *pipeline;
|
|
GstElement *mad;
|
|
gint x;
|
|
GstBus *bus;
|
|
|
|
gst_init (&argc, &argv);
|
|
|
|
if (argc != 2) {
|
|
g_print ("usage: %s <filename>\n", argv[0]);
|
|
exit (-1);
|
|
}
|
|
|
|
/* create a new pipeline to hold the elements */
|
|
pipeline = gst_pipeline_new ("pipeline");
|
|
g_assert (pipeline != NULL);
|
|
|
|
/* create a disk reader */
|
|
filesrc = gst_element_factory_make ("filesrc", "disk_source");
|
|
g_assert (filesrc != NULL);
|
|
g_object_set (G_OBJECT (filesrc), "location", argv[1], NULL);
|
|
|
|
/* and an audio sink */
|
|
osssink = gst_element_factory_make ("osssink", "play_audio");
|
|
g_assert (osssink != NULL);
|
|
|
|
/* did i mention that this is an mp3 player? */
|
|
mad = gst_element_factory_make ("mad", "mp3_decoder");
|
|
g_assert (mad != NULL);
|
|
|
|
gst_bin_add_many (GST_BIN (pipeline), filesrc, mad, osssink, NULL);
|
|
gst_element_link_many (filesrc, mad, osssink, NULL);
|
|
|
|
loop = g_main_loop_new (NULL, FALSE);
|
|
g_timeout_add (2 * 1000, (GSourceFunc) timeout_func, loop);
|
|
|
|
bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));
|
|
gst_bus_add_watch (bus, (GstBusHandler) bus_handler, pipeline);
|
|
|
|
for (x = 0; x < 10; x++) {
|
|
g_print ("playing %d\n", x);
|
|
gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_PLAYING);
|
|
g_main_loop_run (loop);
|
|
if (EOS)
|
|
break;
|
|
|
|
g_print ("pausing %d\n", x);
|
|
gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_PAUSED);
|
|
g_main_loop_run (loop);
|
|
}
|
|
|
|
exit (0);
|
|
}
|