[spice-gtk v1 3/6] gstaudio: rely on SpiceSession init of GStreamer

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Victor Toso <me@xxxxxxxxxxxxxx>

This means we can drop gstvideo_init() function and replace its calls
with gst_is_initialized().

A small code refactor was done in spice_gstaudio_new() to make a early
return on error.

Signed-off-by: Victor Toso <victortoso@xxxxxxxxxx>
---
 src/spice-gstaudio.c | 59 ++++++++++++++++++++------------------------
 1 file changed, 27 insertions(+), 32 deletions(-)

diff --git a/src/spice-gstaudio.c b/src/spice-gstaudio.c
index 5f4a2fe..9be647b 100644
--- a/src/spice-gstaudio.c
+++ b/src/spice-gstaudio.c
@@ -552,45 +552,40 @@ static gboolean connect_channel(SpiceAudio *audio, SpiceChannel *channel)
 SpiceGstaudio *spice_gstaudio_new(SpiceSession *session, GMainContext *context,
                                   const char *name)
 {
-    GError *err = NULL;
-
-    if (gst_init_check(NULL, NULL, &err)) {
-        GstPluginFeature *pulsesrc;
-
-        pulsesrc = gst_registry_lookup_feature(gst_registry_get(), "pulsesrc");
-        if (pulsesrc) {
-            unsigned major, minor, micro;
-            GstPlugin *plugin = gst_plugin_feature_get_plugin(pulsesrc);
-
-            if (sscanf(gst_plugin_get_version(plugin), "%u.%u.%u",
-                       &major, &minor, &micro) != 3) {
-                g_warn_if_reached();
-                gst_object_unref(plugin);
-                gst_object_unref(pulsesrc);
-                return NULL;
-            }
-
-            if (major < 1 ||
-                (major == 1 && minor < 14) ||
-                (major == 1 && minor == 14 && micro < 5)) {
-                g_warning("Bad pulsesrc version %s, lowering its rank",
-                          gst_plugin_get_version(plugin));
-                gst_plugin_feature_set_rank(pulsesrc, GST_RANK_NONE);
-            }
+    if (!gst_is_initialized()) {
+        g_warning("GStreamer not initialized: disabling GStreamer audio support");
+        return NULL;
+    }
+
+    GstPluginFeature *pulsesrc = gst_registry_lookup_feature(gst_registry_get(), "pulsesrc");
+    if (pulsesrc) {
+        unsigned major, minor, micro;
+        GstPlugin *plugin = gst_plugin_feature_get_plugin(pulsesrc);
 
+        if (sscanf(gst_plugin_get_version(plugin), "%u.%u.%u",
+                   &major, &minor, &micro) != 3) {
+            g_warn_if_reached();
             gst_object_unref(plugin);
             gst_object_unref(pulsesrc);
+            return NULL;
+        }
+
+        if (major < 1 ||
+            (major == 1 && minor < 14) ||
+            (major == 1 && minor == 14 && micro < 5)) {
+            g_warning("Bad pulsesrc version %s, lowering its rank",
+                      gst_plugin_get_version(plugin));
+            gst_plugin_feature_set_rank(pulsesrc, GST_RANK_NONE);
         }
 
-        return g_object_new(SPICE_TYPE_GSTAUDIO,
-                            "session", session,
-                            "main-context", context,
-                            NULL);
+        gst_object_unref(plugin);
+        gst_object_unref(pulsesrc);
     }
 
-    g_warning("Disabling GStreamer audio support: %s", err->message);
-    g_clear_error(&err);
-    return NULL;
+    return g_object_new(SPICE_TYPE_GSTAUDIO,
+                        "session", session,
+                        "main-context", context,
+                        NULL);
 }
 
 static void spice_gstaudio_get_playback_volume_info_async(SpiceAudio *audio,
-- 
2.21.0

_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/spice-devel




[Index of Archives]     [Linux Virtualization]     [Linux Virtualization]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]