[spice-gtk v2 2/3] display-gst: 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 rework on create_gstreamer_decoder() was done to make
gst_is_initialized() return early with proper debug message related to
lack of GStreamer initialization.

Signed-off-by: Victor Toso <victortoso@xxxxxxxxxx>
---
 src/channel-display-gst.c | 55 ++++++++++++++++-----------------------
 1 file changed, 22 insertions(+), 33 deletions(-)

diff --git a/src/channel-display-gst.c b/src/channel-display-gst.c
index 6fccf62..c88788f 100644
--- a/src/channel-display-gst.c
+++ b/src/channel-display-gst.c
@@ -748,44 +748,30 @@ static gboolean spice_gst_decoder_queue_frame(VideoDecoder *video_decoder,
     return TRUE;
 }
 
-static gboolean gstvideo_init(void)
-{
-    static int success = 0;
-    if (!success) {
-        GError *err = NULL;
-        if (gst_init_check(NULL, NULL, &err)) {
-            success = 1;
-        } else {
-            spice_warning("Disabling GStreamer video support: %s", err->message);
-            g_clear_error(&err);
-            success = -1;
-        }
-    }
-    return success > 0;
-}
-
 G_GNUC_INTERNAL
 VideoDecoder* create_gstreamer_decoder(int codec_type, display_stream *stream)
 {
-    SpiceGstDecoder *decoder = NULL;
 
     g_return_val_if_fail(VALID_VIDEO_CODEC_TYPE(codec_type), NULL);
 
-    if (gstvideo_init()) {
-        decoder = g_new0(SpiceGstDecoder, 1);
-        decoder->base.destroy = spice_gst_decoder_destroy;
-        decoder->base.reschedule = spice_gst_decoder_reschedule;
-        decoder->base.queue_frame = spice_gst_decoder_queue_frame;
-        decoder->base.codec_type = codec_type;
-        decoder->base.stream = stream;
-        decoder->last_mm_time = stream_get_time(stream);
-        g_mutex_init(&decoder->queues_mutex);
-        decoder->decoding_queue = g_queue_new();
-
-        if (!create_pipeline(decoder)) {
-            decoder->base.destroy((VideoDecoder*)decoder);
-            decoder = NULL;
-        }
+    if (!gst_is_initialized()) {
+        spice_debug("GStreamer is not initialized: No decoder for codec-type: %u", codec_type);
+        return NULL;
+    }
+
+    SpiceGstDecoder *decoder = g_new0(SpiceGstDecoder, 1);
+    decoder->base.destroy = spice_gst_decoder_destroy;
+    decoder->base.reschedule = spice_gst_decoder_reschedule;
+    decoder->base.queue_frame = spice_gst_decoder_queue_frame;
+    decoder->base.codec_type = codec_type;
+    decoder->base.stream = stream;
+    decoder->last_mm_time = stream_get_time(stream);
+    g_mutex_init(&decoder->queues_mutex);
+    decoder->decoding_queue = g_queue_new();
+
+    if (!create_pipeline(decoder)) {
+        decoder->base.destroy((VideoDecoder*)decoder);
+        return NULL;
     }
 
     return (VideoDecoder*)decoder;
@@ -820,7 +806,10 @@ gboolean gstvideo_has_codec(int codec_type)
     GstCaps *caps;
     GstElementFactoryListType type;
 
-    g_return_val_if_fail(gstvideo_init(), FALSE);
+    if (!gst_is_initialized()) {
+        return FALSE;
+    }
+
     g_return_val_if_fail(VALID_VIDEO_CODEC_TYPE(codec_type), FALSE);
 
     type = GST_ELEMENT_FACTORY_TYPE_DECODER |
-- 
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]