From a9cde8bf1420bbb01f568e4e56647d1b16e7d496 Mon Sep 17 00:00:00 2001 From: Benjamin Franzke Date: Sat, 23 Nov 2013 11:11:55 +0100 Subject: Timestamp playback buffers with appropriate flags * GST_BUFFER_FLAG_DISCONT helps to play immediately after a pause (i.e. no talking) TODO: Not sure GST_BUFFER_FLAG_RESYNC does really help, but from the decoumentation it does what we want. --- src/audio.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/audio.c b/src/audio.c index b1d46b3..e40b1c2 100644 --- a/src/audio.c +++ b/src/audio.c @@ -40,6 +40,7 @@ cmumble_audio_push(struct cmumble *cm, struct cmumble_user *user, */ gstbuf = gst_buffer_new_wrapped(g_memdup(data, size), size); + GST_BUFFER_FLAG_SET(gstbuf, GST_BUFFER_FLAG_LIVE); /* Asume packets are in order, since we're using tcp tunnel only atm. * FIXME: This assumption is probably wrong, since the packets may have @@ -47,19 +48,18 @@ cmumble_audio_push(struct cmumble *cm, struct cmumble_user *user, if (user->last_sequence < 0 || sequence == 0 || sequence < (user->last_sequence + 1)) { + GST_BUFFER_FLAG_SET(gstbuf, GST_BUFFER_FLAG_DISCONT); GST_BUFFER_FLAG_SET(gstbuf, GST_BUFFER_FLAG_RESYNC); time = now - base; if (cm->verbose) g_print("%s: set time to now\n", __func__); -#if 0 - /* FIXME: is this a good idea, in case the pipeline paused - * because we pushed no more buffers? */ - gst_element_set_state(user->pipeline, GST_STATE_PLAYING); -#endif } else if (sequence >= user->last_sequence + 1) { gint64 num = sequence - (user->last_sequence + 1); - time = user->last_time_end + - gst_util_uint64_scale_int(num, GST_SECOND, 100); + time = user->last_time_end; + if (num > 0) { + time += gst_util_uint64_scale_int(num, GST_SECOND, 100); + GST_BUFFER_FLAG_SET(gstbuf, GST_BUFFER_FLAG_DISCONT); + } if (cm->verbose) g_print("%s: set time by sequence: %lu, now: %lu\n", __func__, time, now - base); @@ -67,6 +67,7 @@ cmumble_audio_push(struct cmumble *cm, struct cmumble_user *user, } if (time < (now - base)) { + GST_BUFFER_FLAG_SET(gstbuf, GST_BUFFER_FLAG_DISCONT); GST_BUFFER_FLAG_SET(gstbuf, GST_BUFFER_FLAG_RESYNC); time = now - base; if (cm->verbose) -- cgit