diff options
author | Francois Gouget <fgouget@codeweavers.com> | 2016-08-11 12:21:59 +0200 |
---|---|---|
committer | Victor Toso <victortoso@redhat.com> | 2016-08-12 14:41:16 +0200 |
commit | 12a92b8d02a0d382936f467289a17efe350b4a4f (patch) | |
tree | 74f5d98623ee0ac8f4b877b6a2f1a7e63e8851a3 | |
parent | 572370ad3a8bcc980e6004f025b3d71f98348110 (diff) |
streaming: Don't crash if no frame was received before closing the stream
Signed-off-by: Francois Gouget <fgouget@codeweavers.com>
Acked-by: Victor Toso <victortoso@redhat.com>
-rw-r--r-- | src/channel-display.c | 39 |
1 files changed, 20 insertions, 19 deletions
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); |