4 static GMainLoop *loop;
6 /* eos will be called when the src element has an end of stream */
8 eos (GstElement * element, gpointer data)
10 GstThread *thread = GST_THREAD (data);
12 g_print ("have eos, quitting\n");
15 gst_element_set_state (GST_ELEMENT (thread), GST_STATE_NULL);
17 g_main_loop_quit (loop);
18 g_main_loop_unref (loop);
22 main (int argc, char *argv[])
24 GstElement *filesrc, *osssink;
28 gst_init (&argc, &argv);
31 g_print ("usage: %s <filename>\n", argv[0]);
35 /* create a new thread to hold the elements */
36 thread = gst_thread_new ("thread");
37 g_assert (thread != NULL);
39 /* create a new bin to hold the elements */
40 pipeline = gst_pipeline_new ("pipeline");
41 g_assert (pipeline != NULL);
43 /* create a disk reader */
44 filesrc = gst_element_factory_make ("filesrc", "disk_source");
45 g_assert (filesrc != NULL);
46 g_object_set (G_OBJECT (filesrc), "location", argv[1], NULL);
47 g_signal_connect (G_OBJECT (filesrc), "eos", G_CALLBACK (eos), thread);
49 /* and an audio sink */
50 osssink = gst_element_factory_make ("osssink", "play_audio");
51 g_assert (osssink != NULL);
53 /* add objects to the main pipeline */
55 gst_pipeline_add_src(GST_PIPELINE(pipeline), filesrc);
56 gst_pipeline_add_sink(GST_PIPELINE(pipeline), osssink);
58 if (!gst_pipeline_autoplug(GST_PIPELINE(pipeline))) {
59 g_print("unable to handle stream\n");
64 /*gst_bin_remove(GST_BIN(pipeline), filesrc); */
66 /*gst_bin_add(GST_BIN(thread), filesrc); */
67 gst_bin_add (GST_BIN (thread), GST_ELEMENT (pipeline));
70 gst_element_set_state (GST_ELEMENT (thread), GST_STATE_READY);
72 gst_element_set_state (GST_ELEMENT (thread), GST_STATE_PLAYING);
74 loop = g_main_loop_new (NULL, FALSE);
76 gst_object_unref (thread);