summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorMathieu Duponchelle <mathieu@centricular.com>2019-09-30 16:11:18 +0200
committerMathieu Duponchelle <mduponchelle1@gmail.com>2019-09-30 18:54:12 +0000
commit0e1da383a7bb9083184779cced152c0a57442b14 (patch)
tree4a5f7d72e1529e9750e13f7d0e895d9945f91ed3 /tools
parent606ab04cd69db53ea68b53808b9d8904a42c7127 (diff)
downloadgstreamer-plugins-base-0e1da383a7bb9083184779cced152c0a57442b14.tar.gz
device-monitor: fix device listing without --follow
In !427, I removed the call to get_devices in order to always print added devices from the bus handler, however this requires the main loop to run until all pending messages have been consumed. This commit achieves this by always running the main loop, and simply adding an idle source to quit it in the non --follow case.
Diffstat (limited to 'tools')
-rw-r--r--tools/gst-device-monitor.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/tools/gst-device-monitor.c b/tools/gst-device-monitor.c
index 5765de43b..2b802c392 100644
--- a/tools/gst-device-monitor.c
+++ b/tools/gst-device-monitor.c
@@ -268,6 +268,13 @@ bus_msg_handler (GstBus * bus, GstMessage * msg, gpointer user_data)
return TRUE;
}
+static gboolean
+quit_loop (GMainLoop * loop)
+{
+ g_main_loop_quit (loop);
+ return G_SOURCE_REMOVE;
+}
+
int
main (int argc, char **argv)
{
@@ -364,12 +371,16 @@ main (int argc, char **argv)
GST_INFO ("Took %.2f seconds", g_timer_elapsed (timer, NULL));
- if (follow) {
+ if (!follow) {
+ /* Consume all the messages pending on the bus and exit */
+ g_idle_add ((GSourceFunc) quit_loop, app.loop);
+ } else {
g_print ("Monitoring devices, waiting for devices to be removed or "
"new devices to be added...\n");
- g_main_loop_run (app.loop);
}
+ g_main_loop_run (app.loop);
+
gst_device_monitor_stop (app.monitor);
gst_object_unref (app.monitor);