device-monitor: Use gst_print instead of g_print

Avoid broken stdout output on Windows. Same change was made for
gst-launch in commit 493a3261a9757b5ade7aec289eb07221966f9eed

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/9467>
This commit is contained in:
Seungha Yang 2025-07-31 20:05:15 +09:00
parent 9522551e1d
commit ffc3d16983

View File

@ -155,9 +155,9 @@ print_structure_field (const GstIdStr * fieldname, const GValue * value,
}
if (val != NULL)
g_print ("\n\t\t%s = %s", gst_id_str_as_str (fieldname), val);
gst_print ("\n\t\t%s = %s", gst_id_str_as_str (fieldname), val);
else
g_print ("\n\t\t%s - could not serialise field of type %s",
gst_print ("\n\t\t%s - could not serialise field of type %s",
gst_id_str_as_str (fieldname), G_VALUE_TYPE_NAME (value));
g_free (val);
@ -170,7 +170,7 @@ print_field (const GstIdStr * fieldname, const GValue * value, gpointer unused)
{
gchar *str = gst_value_serialize (value);
g_print (", %s=%s", gst_id_str_as_str (fieldname), str);
gst_print (", %s=%s", gst_id_str_as_str (fieldname), str);
g_free (str);
return TRUE;
}
@ -191,44 +191,44 @@ print_device (GstDevice * device, gboolean modified)
device_class = gst_device_get_device_class (device);
props = gst_device_get_properties (device);
g_print ("\nDevice %s:\n\n", modified ? "modified" : "found");
g_print ("\tname : %s\n", name);
g_print ("\tclass : %s\n", device_class);
gst_print ("\nDevice %s:\n\n", modified ? "modified" : "found");
gst_print ("\tname : %s\n", name);
gst_print ("\tclass : %s\n", device_class);
for (i = 0; i < size; ++i) {
GstStructure *s = gst_caps_get_structure (caps, i);
GstCapsFeatures *features = gst_caps_get_features (caps, i);
g_print ("\t%s %s", (i == 0) ? "caps :" : " ",
gst_print ("\t%s %s", (i == 0) ? "caps :" : " ",
gst_structure_get_name (s));
if (features && (gst_caps_features_is_any (features) ||
!gst_caps_features_is_equal (features,
GST_CAPS_FEATURES_MEMORY_SYSTEM_MEMORY))) {
gchar *features_string = gst_caps_features_to_string (features);
g_print ("(%s)", features_string);
gst_print ("(%s)", features_string);
g_free (features_string);
}
gst_structure_foreach_id_str (s, print_field, NULL);
g_print ("\n");
gst_print ("\n");
}
if (props) {
g_print ("\tproperties:");
gst_print ("\tproperties:");
gst_structure_foreach_id_str (props, print_structure_field, NULL);
gst_structure_free (props);
g_print ("\n");
gst_print ("\n");
}
str = get_launch_line (device);
if (gst_device_has_classes (device, "Source"))
g_print ("\tgst-launch-1.0 %s ! ...\n", str);
gst_print ("\tgst-launch-1.0 %s ! ...\n", str);
else if (gst_device_has_classes (device, "Sink"))
g_print ("\tgst-launch-1.0 ... ! %s\n", str);
gst_print ("\tgst-launch-1.0 ... ! %s\n", str);
else if (gst_device_has_classes (device, "CameraSource")) {
g_print ("\tgst-launch-1.0 %s.vfsrc name=camerasrc ! ... "
gst_print ("\tgst-launch-1.0 %s.vfsrc name=camerasrc ! ... "
"camerasrc.vidsrc ! [video/x-h264] ... \n", str);
}
g_free (str);
g_print ("\n");
gst_print ("\n");
g_free (name);
g_free (device_class);
@ -244,8 +244,8 @@ device_removed (GstDevice * device)
name = gst_device_get_display_name (device);
g_print ("Device removed:\n");
g_print ("\tname : %s\n", name);
gst_print ("Device removed:\n");
gst_print ("\tname : %s\n", name);
g_free (name);
}
@ -272,7 +272,7 @@ bus_msg_handler (GstBus * bus, GstMessage * msg, gpointer user_data)
gst_object_unref (device);
break;
default:
g_print ("%s message\n", GST_MESSAGE_TYPE_NAME (msg));
gst_print ("%s message\n", GST_MESSAGE_TYPE_NAME (msg));
break;
}
@ -330,7 +330,7 @@ real_main (int argc, char **argv)
if (!g_option_context_parse (ctx, &argc, &argv, &err))
#endif
{
g_print ("Error initializing: %s\n", GST_STR_NULL (err->message));
gst_print ("Error initializing: %s\n", GST_STR_NULL (err->message));
g_option_context_free (ctx);
g_clear_error (&err);
return 1;
@ -348,9 +348,9 @@ real_main (int argc, char **argv)
gchar *version_str;
version_str = gst_version_string ();
g_print ("%s version %s\n", g_get_prgname (), PACKAGE_VERSION);
g_print ("%s\n", version_str);
g_print ("%s\n", GST_PACKAGE_ORIGIN);
gst_print ("%s version %s\n", g_get_prgname (), PACKAGE_VERSION);
gst_print ("%s\n", version_str);
gst_print ("%s\n", GST_PACKAGE_ORIGIN);
g_free (version_str);
return 0;
@ -384,12 +384,12 @@ real_main (int argc, char **argv)
}
g_strfreev (args);
g_print ("Probing devices...\n\n");
gst_print ("Probing devices...\n\n");
timer = g_timer_new ();
if (!gst_device_monitor_start (app.monitor)) {
g_printerr ("Failed to start device monitor!\n");
gst_printerr ("Failed to start device monitor!\n");
return -1;
}
@ -399,7 +399,7 @@ real_main (int argc, char **argv)
/* 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 "
gst_print ("Monitoring devices, waiting for devices to be removed or "
"new devices to be added...\n");
}