mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-19 14:56:36 +00:00
jitterbuffer: use corrected timeout when rescheduling
When we recalculate the timeout, use the corrected timeout value depending on the timer type.
This commit is contained in:
parent
9c7e3e3455
commit
a8c7ff7489
1 changed files with 30 additions and 21 deletions
|
@ -1326,14 +1326,34 @@ unschedule_current_timer (GstRtpJitterBuffer * jitterbuffer)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static GstClockTime
|
||||||
|
get_timeout (GstRtpJitterBuffer * jitterbuffer, TimerData * timer)
|
||||||
|
{
|
||||||
|
GstRtpJitterBufferPrivate *priv = jitterbuffer->priv;
|
||||||
|
GstClockTime test_timeout;
|
||||||
|
|
||||||
|
if ((test_timeout = timer->timeout) == -1)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
if (timer->type != TIMER_TYPE_EXPECTED) {
|
||||||
|
/* add our latency and offset to get output times. */
|
||||||
|
test_timeout = apply_offset (jitterbuffer, test_timeout);
|
||||||
|
test_timeout += priv->latency_ns;
|
||||||
|
}
|
||||||
|
return test_timeout;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
recalculate_timer (GstRtpJitterBuffer * jitterbuffer, TimerData * timer)
|
recalculate_timer (GstRtpJitterBuffer * jitterbuffer, TimerData * timer)
|
||||||
{
|
{
|
||||||
GstRtpJitterBufferPrivate *priv = jitterbuffer->priv;
|
GstRtpJitterBufferPrivate *priv = jitterbuffer->priv;
|
||||||
|
|
||||||
if (priv->clock_id && (timer->timeout == -1
|
if (priv->clock_id) {
|
||||||
|| priv->timer_timeout > timer->timeout))
|
GstClockTime timeout = get_timeout (jitterbuffer, timer);
|
||||||
unschedule_current_timer (jitterbuffer);
|
|
||||||
|
if (timeout == -1 || timeout < priv->timer_timeout)
|
||||||
|
unschedule_current_timer (jitterbuffer);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static TimerData *
|
static TimerData *
|
||||||
|
@ -2131,28 +2151,17 @@ wait_next_timeout (GstRtpJitterBuffer * jitterbuffer)
|
||||||
len = priv->timers->len;
|
len = priv->timers->len;
|
||||||
for (i = 0; i < len; i++) {
|
for (i = 0; i < len; i++) {
|
||||||
TimerData *test = &g_array_index (priv->timers, TimerData, i);
|
TimerData *test = &g_array_index (priv->timers, TimerData, i);
|
||||||
GstClockTime test_timeout;
|
GstClockTime test_timeout = get_timeout (jitterbuffer, test);
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (jitterbuffer, "%d, %d, %" GST_TIME_FORMAT,
|
GST_DEBUG_OBJECT (jitterbuffer, "%d, %d, %" GST_TIME_FORMAT,
|
||||||
i, test->seqnum, GST_TIME_ARGS (test->timeout));
|
i, test->seqnum, GST_TIME_ARGS (test_timeout));
|
||||||
|
|
||||||
test_timeout = test->timeout;
|
|
||||||
if (test_timeout == -1) {
|
|
||||||
timer = test;
|
|
||||||
timer_timeout = test_timeout;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (test->type != TIMER_TYPE_EXPECTED) {
|
|
||||||
/* add our latency and offset to get output times. */
|
|
||||||
test_timeout = apply_offset (jitterbuffer, test_timeout);
|
|
||||||
test_timeout += priv->latency_ns;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* find the smallest timeout */
|
/* find the smallest timeout */
|
||||||
if (timer == NULL || test_timeout < timer_timeout) {
|
if (timer == NULL || test_timeout == -1 || test_timeout < timer_timeout) {
|
||||||
timer = test;
|
timer = test;
|
||||||
timer_timeout = test_timeout;
|
timer_timeout = test_timeout;
|
||||||
|
if (timer_timeout == -1)
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (timer) {
|
if (timer) {
|
||||||
|
@ -2198,8 +2207,8 @@ wait_next_timeout (GstRtpJitterBuffer * jitterbuffer)
|
||||||
ret = gst_clock_id_wait (id, &clock_jitter);
|
ret = gst_clock_id_wait (id, &clock_jitter);
|
||||||
|
|
||||||
JBUF_LOCK (priv);
|
JBUF_LOCK (priv);
|
||||||
GST_DEBUG_OBJECT (jitterbuffer, "sync done, %d, %" G_GINT64_FORMAT,
|
GST_DEBUG_OBJECT (jitterbuffer, "sync done, %d, #%d, %" G_GINT64_FORMAT,
|
||||||
ret, clock_jitter);
|
ret, priv->timer_seqnum, clock_jitter);
|
||||||
/* and free the entry */
|
/* and free the entry */
|
||||||
gst_clock_id_unref (id);
|
gst_clock_id_unref (id);
|
||||||
priv->clock_id = NULL;
|
priv->clock_id = NULL;
|
||||||
|
|
Loading…
Reference in a new issue