mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-11 18:05:37 +00:00
bus: fix timeout handling
This commit is contained in:
parent
442193f3f3
commit
7c8405fa28
1 changed files with 5 additions and 7 deletions
12
gst/gstbus.c
12
gst/gstbus.c
|
@ -468,6 +468,7 @@ gst_bus_timed_pop_filtered (GstBus * bus, GstClockTime timeout,
|
||||||
GstMessage *message;
|
GstMessage *message;
|
||||||
GTimeVal now, then;
|
GTimeVal now, then;
|
||||||
gboolean first_round = TRUE;
|
gboolean first_round = TRUE;
|
||||||
|
GstClockTime elapsed = 0;
|
||||||
|
|
||||||
g_return_val_if_fail (GST_IS_BUS (bus), NULL);
|
g_return_val_if_fail (GST_IS_BUS (bus), NULL);
|
||||||
g_return_val_if_fail (types != 0, NULL);
|
g_return_val_if_fail (types != 0, NULL);
|
||||||
|
@ -505,22 +506,19 @@ gst_bus_timed_pop_filtered (GstBus * bus, GstClockTime timeout,
|
||||||
g_get_current_time (&then);
|
g_get_current_time (&then);
|
||||||
first_round = FALSE;
|
first_round = FALSE;
|
||||||
} else {
|
} else {
|
||||||
GstClockTime elapsed;
|
|
||||||
|
|
||||||
g_get_current_time (&now);
|
g_get_current_time (&now);
|
||||||
|
|
||||||
elapsed = GST_TIMEVAL_TO_TIME (now) - GST_TIMEVAL_TO_TIME (then);
|
elapsed = GST_TIMEVAL_TO_TIME (now) - GST_TIMEVAL_TO_TIME (then);
|
||||||
if (timeout > elapsed)
|
|
||||||
timeout -= elapsed;
|
if (elapsed > timeout)
|
||||||
else
|
break;
|
||||||
timeout = 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* only here in timeout case */
|
/* only here in timeout case */
|
||||||
g_assert (bus->priv->poll);
|
g_assert (bus->priv->poll);
|
||||||
g_mutex_unlock (bus->queue_lock);
|
g_mutex_unlock (bus->queue_lock);
|
||||||
ret = gst_poll_wait (bus->priv->poll, timeout);
|
ret = gst_poll_wait (bus->priv->poll, timeout - elapsed);
|
||||||
g_mutex_lock (bus->queue_lock);
|
g_mutex_lock (bus->queue_lock);
|
||||||
|
|
||||||
if (ret == 0) {
|
if (ret == 0) {
|
||||||
|
|
Loading…
Reference in a new issue