mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-23 15:48:23 +00:00
jitterbuffer: update timers when removing
Update the timers when we remove a timer. Handle canceled timers, make them unschedule the current timer and trigger the timeout code.
This commit is contained in:
parent
b983cf675b
commit
4ab3f5d3da
1 changed files with 17 additions and 4 deletions
|
@ -1313,7 +1313,8 @@ recalculate_timer (GstRtpJitterBuffer * jitterbuffer, TimerData * timer)
|
||||||
{
|
{
|
||||||
GstRtpJitterBufferPrivate *priv = jitterbuffer->priv;
|
GstRtpJitterBufferPrivate *priv = jitterbuffer->priv;
|
||||||
|
|
||||||
if (priv->clock_id && priv->timer_timeout > timer->timeout)
|
if (priv->clock_id && (timer->timeout == -1
|
||||||
|
|| priv->timer_timeout > timer->timeout))
|
||||||
unschedule_current_timer (jitterbuffer);
|
unschedule_current_timer (jitterbuffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1360,14 +1361,18 @@ reschedule_timer (GstRtpJitterBuffer * jitterbuffer, TimerData * timer,
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (jitterbuffer,
|
GST_DEBUG_OBJECT (jitterbuffer,
|
||||||
"replace timer for seqnum %d->%d to %" GST_TIME_FORMAT,
|
"replace timer for seqnum %d->%d to %" GST_TIME_FORMAT,
|
||||||
timer->seqnum, seqnum, GST_TIME_ARGS (timeout));
|
oldseq, seqnum, GST_TIME_ARGS (timeout));
|
||||||
|
|
||||||
timer->timeout = timeout;
|
timer->timeout = timeout;
|
||||||
timer->seqnum = seqnum;
|
timer->seqnum = seqnum;
|
||||||
|
|
||||||
if (priv->clock_id) {
|
if (priv->clock_id) {
|
||||||
|
/* we changed the seqnum and there is a timer currently waiting with this
|
||||||
|
* seqnum, unschedule it */
|
||||||
if (seqchange && priv->timer_seqnum == oldseq)
|
if (seqchange && priv->timer_seqnum == oldseq)
|
||||||
unschedule_current_timer (jitterbuffer);
|
unschedule_current_timer (jitterbuffer);
|
||||||
|
/* we changed the time, check if it is earlier than what we are waiting
|
||||||
|
* for and unschedule if so */
|
||||||
else if (timechange)
|
else if (timechange)
|
||||||
recalculate_timer (jitterbuffer, timer);
|
recalculate_timer (jitterbuffer, timer);
|
||||||
}
|
}
|
||||||
|
@ -1398,6 +1403,9 @@ remove_timer (GstRtpJitterBuffer * jitterbuffer, TimerData * timer)
|
||||||
if (timer == NULL)
|
if (timer == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (priv->clock_id && priv->timer_seqnum == timer->seqnum)
|
||||||
|
unschedule_current_timer (jitterbuffer);
|
||||||
|
|
||||||
idx = timer->idx;
|
idx = timer->idx;
|
||||||
GST_DEBUG_OBJECT (jitterbuffer, "removed index %d", idx);
|
GST_DEBUG_OBJECT (jitterbuffer, "removed index %d", idx);
|
||||||
g_array_remove_index_fast (priv->timers, idx);
|
g_array_remove_index_fast (priv->timers, idx);
|
||||||
|
@ -1410,6 +1418,7 @@ remove_all_timers (GstRtpJitterBuffer * jitterbuffer)
|
||||||
GstRtpJitterBufferPrivate *priv = jitterbuffer->priv;
|
GstRtpJitterBufferPrivate *priv = jitterbuffer->priv;
|
||||||
GST_DEBUG_OBJECT (jitterbuffer, "removed all timers");
|
GST_DEBUG_OBJECT (jitterbuffer, "removed all timers");
|
||||||
g_array_set_size (priv->timers, 0);
|
g_array_set_size (priv->timers, 0);
|
||||||
|
unschedule_current_timer (jitterbuffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -2160,6 +2169,12 @@ wait_next_timeout (GstRtpJitterBuffer * jitterbuffer)
|
||||||
((priv->srcresult != GST_FLOW_OK))
|
((priv->srcresult != GST_FLOW_OK))
|
||||||
goto flushing;
|
goto flushing;
|
||||||
|
|
||||||
|
/* we released the lock, the array might have changed */
|
||||||
|
timer = &g_array_index (priv->timers, TimerData, timer_idx);
|
||||||
|
/* if changed to timeout immediately, do so */
|
||||||
|
if (timer->timeout == -1)
|
||||||
|
goto do_timeout;
|
||||||
|
|
||||||
/* if we got unscheduled and we are not flushing, it's because a new tail
|
/* if we got unscheduled and we are not flushing, it's because a new tail
|
||||||
* element became available in the queue or we flushed the queue.
|
* element became available in the queue or we flushed the queue.
|
||||||
* Grab it and try to push or sync. */
|
* Grab it and try to push or sync. */
|
||||||
|
@ -2168,8 +2183,6 @@ wait_next_timeout (GstRtpJitterBuffer * jitterbuffer)
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* we released the lock, the array might have changed */
|
|
||||||
timer = &g_array_index (priv->timers, TimerData, timer_idx);
|
|
||||||
do_timeout:
|
do_timeout:
|
||||||
switch (timer->type) {
|
switch (timer->type) {
|
||||||
case TIMER_TYPE_EXPECTED:
|
case TIMER_TYPE_EXPECTED:
|
||||||
|
|
Loading…
Reference in a new issue