From: Ravi Kiran K N Date: Wed, 29 Oct 2014 10:58:28 +0000 (+0530) Subject: tests/playback: quit from main loop X-Git-Tag: 1.19.3~511^2~4214 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e0028c77f61c7d8d297552f6cd8194c021e49237;p=platform%2Fupstream%2Fgstreamer.git tests/playback: quit from main loop Listen for eos and error signal to quit main loop. https://bugzilla.gnome.org/show_bug.cgi?id=739346 --- diff --git a/tests/icles/playback/test.c b/tests/icles/playback/test.c index da09fca..6a8026f 100644 --- a/tests/icles/playback/test.c +++ b/tests/icles/playback/test.c @@ -139,11 +139,18 @@ link_failed: } } +static void +error_eos_cb (GstBus * bus, GstMessage * msg, GMainLoop * main_loop) +{ + g_main_loop_quit (main_loop); +} + gint main (gint argc, gchar * argv[]) { GstElement *pipeline, *filesrc, *decodebin; GstStateChangeReturn res; + GstBus *bus; gst_init (&argc, &argv); @@ -154,6 +161,13 @@ main (gint argc, gchar * argv[]) decodebin = gst_element_factory_make ("decodebin", "decodebin"); g_assert (decodebin); + loop = g_main_loop_new (NULL, TRUE); + bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline)); + gst_bus_add_signal_watch (bus); + + g_signal_connect (bus, "message::eos", G_CALLBACK (error_eos_cb), loop); + g_signal_connect (bus, "message::error", G_CALLBACK (error_eos_cb), loop); + g_signal_connect (G_OBJECT (decodebin), "pad-added", G_CALLBACK (pad_added_cb), pipeline); @@ -193,7 +207,6 @@ main (gint argc, gchar * argv[]) } /* go in the mainloop now */ - loop = g_main_loop_new (NULL, TRUE); g_main_loop_run (loop); return 0; diff --git a/tests/icles/playback/test2.c b/tests/icles/playback/test2.c index 9801ae0..5cf0d7e 100644 --- a/tests/icles/playback/test2.c +++ b/tests/icles/playback/test2.c @@ -18,11 +18,20 @@ */ #include +static GMainLoop *loop; + +static void +error_eos_cb (GstBus * bus, GstMessage * msg, GMainLoop * main_loop) +{ + g_main_loop_quit (main_loop); +} + gint main (gint argc, gchar * argv[]) { GstElement *player; GstStateChangeReturn res; + GstBus *bus; gst_init (&argc, &argv); @@ -31,13 +40,20 @@ main (gint argc, gchar * argv[]) g_object_set (G_OBJECT (player), "uri", argv[1], NULL); + loop = g_main_loop_new (NULL, TRUE); + bus = gst_pipeline_get_bus (GST_PIPELINE (player)); + gst_bus_add_signal_watch (bus); + + g_signal_connect (bus, "message::eos", G_CALLBACK (error_eos_cb), loop); + g_signal_connect (bus, "message::error", G_CALLBACK (error_eos_cb), loop); + res = gst_element_set_state (player, GST_STATE_PLAYING); if (res == GST_STATE_CHANGE_FAILURE) { g_print ("could not play\n"); return -1; } - g_main_loop_run (g_main_loop_new (NULL, TRUE)); + g_main_loop_run (loop); return 0; } diff --git a/tests/icles/playback/test4.c b/tests/icles/playback/test4.c index 410bacf..d036d7f 100644 --- a/tests/icles/playback/test4.c +++ b/tests/icles/playback/test4.c @@ -28,11 +28,20 @@ #include +static GMainLoop *loop; + +static void +error_eos_cb (GstBus * bus, GstMessage * msg, GMainLoop * main_loop) +{ + g_main_loop_quit (main_loop); +} + gint main (gint argc, gchar * argv[]) { GstElement *player; GstStateChangeReturn res; + GstBus *bus; gst_init (&argc, &argv); @@ -44,6 +53,13 @@ main (gint argc, gchar * argv[]) exit (-1); } + loop = g_main_loop_new (NULL, TRUE); + bus = gst_pipeline_get_bus (GST_PIPELINE (player)); + gst_bus_add_signal_watch (bus); + + g_signal_connect (bus, "message::eos", G_CALLBACK (error_eos_cb), loop); + g_signal_connect (bus, "message::error", G_CALLBACK (error_eos_cb), loop); + g_object_set (G_OBJECT (player), "uri", argv[1], NULL); g_print ("play...\n"); @@ -93,7 +109,7 @@ main (gint argc, gchar * argv[]) return -1; } - g_main_loop_run (g_main_loop_new (NULL, TRUE)); + g_main_loop_run (loop); return 0; }