[Spice-commits] 3 commits - src/channel-display.c src/channel-display-gst.c

Victor Toso de Carvalho victortoso at kemper.freedesktop.org
Fri Aug 12 12:43:34 UTC 2016


 src/channel-display-gst.c |   12 ++++++------
 src/channel-display.c     |   44 +++++++++++++++++++++++++-------------------
 2 files changed, 31 insertions(+), 25 deletions(-)

New commits:
commit 2674ec79457b641c60b6a352585bee354e360b98
Author: Francois Gouget <fgouget at codeweavers.com>
Date:   Thu Aug 11 12:22:24 2016 +0200

    streaming: Create the pipeline at the same time as the GStreamer decoder
    
    This lets create_gstreamer_decoder() fail if it cannot create the
    pipeline it needs, allowing the caller to try fallbacks.
    This also means the pipeline has the same lifetime as the decoder which
    makes it possible to remove a check in queue_frame().
    
    Signed-off-by: Francois Gouget <fgouget at codeweavers.com>
    Acked-by: Victor Toso <victortoso at redhat.com>

diff --git a/src/channel-display-gst.c b/src/channel-display-gst.c
index c752639..430bb95 100644
--- a/src/channel-display-gst.c
+++ b/src/channel-display-gst.c
@@ -407,11 +407,6 @@ static void spice_gst_decoder_queue_frame(VideoDecoder *video_decoder,
         return;
     }
 
-    if (!decoder->pipeline && !create_pipeline(decoder)) {
-        stream_dropped_frame_on_playback(decoder->base.stream);
-        return;
-    }
-
     /* ref() the frame_msg for the buffer */
     spice_msg_in_ref(frame_msg);
     GstBuffer *buffer = gst_buffer_new_wrapped_full(GST_MEMORY_FLAG_PHYSICALLY_CONTIGUOUS,
@@ -463,6 +458,11 @@ VideoDecoder* create_gstreamer_decoder(int codec_type, display_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;
+        }
     }
 
     return (VideoDecoder*)decoder;
@@ -475,7 +475,7 @@ gboolean gstvideo_has_codec(int codec_type)
 
     VideoDecoder *decoder = create_gstreamer_decoder(codec_type, NULL);
     if (decoder) {
-        has_codec = create_pipeline((SpiceGstDecoder*)decoder);
+        has_codec = TRUE;
         decoder->destroy(decoder);
     }
 
commit dbaa3238eebf9b7bc0ec59fcf2df856d28e6a5e1
Author: Francois Gouget <fgouget at codeweavers.com>
Date:   Thu Aug 11 12:22:08 2016 +0200

    streaming: Don't crash if the stream creation fails
    
    Note that this implies closing the stream before receiving any frame.
    
    Signed-off-by: Francois Gouget <fgouget at codeweavers.com>
    Acked-by: Victor Toso <victortoso at redhat.com>

diff --git a/src/channel-display.c b/src/channel-display.c
index 22c54f2..709b3d2 100644
--- a/src/channel-display.c
+++ b/src/channel-display.c
@@ -109,6 +109,7 @@ static display_surface *find_surface(SpiceDisplayChannelPrivate *c, guint32 surf
 static void spice_display_channel_reset(SpiceChannel *channel, gboolean migrating);
 static void spice_display_channel_reset_capabilities(SpiceChannel *channel);
 static void destroy_canvas(display_surface *surface);
+static void destroy_stream(SpiceChannel *channel, int id);
 static void display_session_mm_time_reset_cb(SpiceSession *session, gpointer data);
 static SpiceGlScanout* spice_gl_scanout_copy(const SpiceGlScanout *scanout);
 
@@ -1125,6 +1126,7 @@ static void display_handle_stream_create(SpiceChannel *channel, SpiceMsgIn *in)
     }
     if (st->video_decoder == NULL) {
         spice_printerr("could not create a video decoder for codec %u", op->codec_type);
+        destroy_stream(channel, op->id);
     }
 }
 
@@ -1231,6 +1233,7 @@ static void display_update_stream_report(SpiceDisplayChannel *channel, uint32_t
     g_return_if_fail(c->nstreams > stream_id);
 
     st = channel->priv->streams[stream_id];
+    g_return_if_fail(st != NULL);
 
     if (!st->report_is_active) {
         return;
@@ -1353,6 +1356,7 @@ static void display_handle_stream_data(SpiceChannel *channel, SpiceMsgIn *in)
     g_return_if_fail(c->nstreams > op->id);
 
     st =  c->streams[op->id];
+    g_return_if_fail(st != NULL);
     mmtime = stream_get_time(st);
 
     if (spice_msg_in_type(in) == SPICE_MSG_DISPLAY_STREAM_DATA_SIZED) {
@@ -1420,6 +1424,7 @@ static void display_handle_stream_clip(SpiceChannel *channel, SpiceMsgIn *in)
     g_return_if_fail(c->nstreams > op->id);
 
     st = c->streams[op->id];
+    g_return_if_fail(st != NULL);
 
     if (st->msg_clip) {
         spice_msg_in_unref(st->msg_clip);
commit 12a92b8d02a0d382936f467289a17efe350b4a4f
Author: Francois Gouget <fgouget at codeweavers.com>
Date:   Thu Aug 11 12:21:59 2016 +0200

    streaming: Don't crash if no frame was received before closing the stream
    
    Signed-off-by: Francois Gouget <fgouget at codeweavers.com>
    Acked-by: Victor Toso <victortoso at redhat.com>

diff --git a/src/channel-display.c b/src/channel-display.c
index b4c9ec0..22c54f2 100644
--- a/src/channel-display.c
+++ b/src/channel-display.c
@@ -1434,8 +1434,6 @@ static void destroy_stream(SpiceChannel *channel, int id)
 {
     SpiceDisplayChannelPrivate *c = SPICE_DISPLAY_CHANNEL(channel)->priv;
     display_stream *st;
-    guint64 drops_duration_total = 0;
-    guint32 num_out_frames;
     int i;
 
     g_return_if_fail(c != NULL);
@@ -1446,20 +1444,22 @@ static void destroy_stream(SpiceChannel *channel, int id)
     if (!st)
         return;
 
-    num_out_frames = st->num_input_frames - st->arrive_late_count - st->num_drops_on_playback;
-    CHANNEL_DEBUG(channel, "%s: id=%d #in-frames=%u out/in=%.2f "
-        "#drops-on-receive=%u avg-late-time(ms)=%.2f "
-        "#drops-on-playback=%u", __FUNCTION__,
-        id,
-        st->num_input_frames,
-        num_out_frames / (double)st->num_input_frames,
-        st->arrive_late_count,
-        st->arrive_late_count ? st->arrive_late_time / ((double)st->arrive_late_count): 0,
-        st->num_drops_on_playback);
-    if (st->num_drops_seqs) {
-        CHANNEL_DEBUG(channel, "%s: #drops-sequences=%u ==>", __FUNCTION__, st->num_drops_seqs);
-    }
-    for (i = 0; i < st->num_drops_seqs; i++) {
+    if (st->num_input_frames > 0) {
+        guint64 drops_duration_total = 0;
+        guint32 num_out_frames = st->num_input_frames - st->arrive_late_count - st->num_drops_on_playback;
+        CHANNEL_DEBUG(channel, "%s: id=%d #in-frames=%u out/in=%.2f "
+            "#drops-on-receive=%u avg-late-time(ms)=%.2f "
+            "#drops-on-playback=%u", __FUNCTION__,
+            id,
+            st->num_input_frames,
+            num_out_frames / (double)st->num_input_frames,
+            st->arrive_late_count,
+            st->arrive_late_count ? st->arrive_late_time / ((double)st->arrive_late_count): 0,
+            st->num_drops_on_playback);
+        if (st->num_drops_seqs) {
+            CHANNEL_DEBUG(channel, "%s: #drops-sequences=%u ==>", __FUNCTION__, st->num_drops_seqs);
+        }
+        for (i = 0; i < st->num_drops_seqs; i++) {
             drops_sequence_stats *stats = &g_array_index(st->drops_seqs_stats_arr,
                                                          drops_sequence_stats,
                                                          i);
@@ -1468,9 +1468,10 @@ static void destroy_stream(SpiceChannel *channel, int id)
                                    stats->len,
                                    stats->start_mm_time - st->first_frame_mm_time,
                                    stats->duration);
-    }
-    if (st->num_drops_seqs) {
-        CHANNEL_DEBUG(channel, "%s: drops-total-duration=%"G_GUINT64_FORMAT" ==>", __FUNCTION__, drops_duration_total);
+        }
+        if (st->num_drops_seqs) {
+            CHANNEL_DEBUG(channel, "%s: drops-total-duration=%"G_GUINT64_FORMAT" ==>", __FUNCTION__, drops_duration_total);
+        }
     }
 
     g_array_free(st->drops_seqs_stats_arr, TRUE);


More information about the Spice-commits mailing list