[Spice-devel] [spice-gtk v1 4/4] channel-display-gst: early return if gst_init failed

Victor Toso victortoso at redhat.com
Tue Oct 18 21:27:07 UTC 2016


From: Victor Toso <me at victortoso.com>

If gst_init() fails, gstvideo_init() will warn once about the issue
and never attempt to try again, which is probably fine.

All the other APIs that might be called such as
create_gstreamer_decoder() should not fail silently.

Signed-off-by: Victor Toso <victortoso at redhat.com>
---
 src/channel-display-gst.c | 34 +++++++++++++++++-----------------
 1 file changed, 17 insertions(+), 17 deletions(-)

diff --git a/src/channel-display-gst.c b/src/channel-display-gst.c
index c0f0a1e..c102966 100644
--- a/src/channel-display-gst.c
+++ b/src/channel-display-gst.c
@@ -459,23 +459,23 @@ static gboolean gstvideo_init(void)
 G_GNUC_INTERNAL
 VideoDecoder* create_gstreamer_decoder(int codec_type, display_stream *stream)
 {
-    SpiceGstDecoder *decoder = NULL;
-
-    if (gstvideo_init()) {
-        decoder = spice_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;
-        g_mutex_init(&decoder->queues_mutex);
-        decoder->decoding_queue = g_queue_new();
-        decoder->display_queue = g_queue_new();
-
-        if (!create_pipeline(decoder)) {
-            decoder->base.destroy((VideoDecoder*)decoder);
-            decoder = NULL;
-        }
+    SpiceGstDecoder *decoder;
+
+    g_return_val_if_fail(gstvideo_init(), NULL);
+
+    decoder = spice_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;
+    g_mutex_init(&decoder->queues_mutex);
+    decoder->decoding_queue = g_queue_new();
+    decoder->display_queue = g_queue_new();
+
+    if (!create_pipeline(decoder)) {
+        decoder->base.destroy((VideoDecoder*)decoder);
+        return NULL;
     }
 
     return (VideoDecoder*)decoder;
-- 
2.9.3



More information about the Spice-devel mailing list