mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-15 22:01:27 +00:00
queues: Don't return negative position queries.
When subtracting queued data sizes from upstream queries in queue, queue2, downloadbuffer and typefind, clamp the result to not go negative, in case upstream returned a nonsense value that's too small (as could happen if upstream is estimating, or just broken)
This commit is contained in:
parent
77566f9151
commit
f8775abcae
4 changed files with 14 additions and 0 deletions
|
@ -1434,9 +1434,13 @@ gst_download_buffer_handle_src_query (GstPad * pad, GstObject * parent,
|
|||
switch (format) {
|
||||
case GST_FORMAT_BYTES:
|
||||
peer_pos -= dlbuf->cur_level.bytes;
|
||||
if (peer_pos < 0) /* Clamp result to 0 */
|
||||
peer_pos = 0;
|
||||
break;
|
||||
case GST_FORMAT_TIME:
|
||||
peer_pos -= dlbuf->cur_level.time;
|
||||
if (peer_pos < 0) /* Clamp result to 0 */
|
||||
peer_pos = 0;
|
||||
break;
|
||||
default:
|
||||
GST_WARNING_OBJECT (dlbuf, "dropping query in %s format, don't "
|
||||
|
|
|
@ -1606,9 +1606,13 @@ gst_queue_handle_src_query (GstPad * pad, GstObject * parent, GstQuery * query)
|
|||
switch (format) {
|
||||
case GST_FORMAT_BYTES:
|
||||
peer_pos -= queue->cur_level.bytes;
|
||||
if (peer_pos < 0) /* Clamp result to 0 */
|
||||
peer_pos = 0;
|
||||
break;
|
||||
case GST_FORMAT_TIME:
|
||||
peer_pos -= queue->cur_level.time;
|
||||
if (peer_pos < 0) /* Clamp result to 0 */
|
||||
peer_pos = 0;
|
||||
break;
|
||||
default:
|
||||
GST_DEBUG_OBJECT (queue, "Can't adjust query in %s format, don't "
|
||||
|
|
|
@ -3155,9 +3155,13 @@ gst_queue2_handle_src_query (GstPad * pad, GstObject * parent, GstQuery * query)
|
|||
switch (format) {
|
||||
case GST_FORMAT_BYTES:
|
||||
peer_pos -= queue->cur_level.bytes;
|
||||
if (peer_pos < 0) /* Clamp result to 0 */
|
||||
peer_pos = 0;
|
||||
break;
|
||||
case GST_FORMAT_TIME:
|
||||
peer_pos -= queue->cur_level.time;
|
||||
if (peer_pos < 0) /* Clamp result to 0 */
|
||||
peer_pos = 0;
|
||||
break;
|
||||
default:
|
||||
GST_WARNING_OBJECT (queue, "dropping query in %s format, don't "
|
||||
|
|
|
@ -450,6 +450,8 @@ gst_type_find_handle_src_query (GstPad * pad, GstObject * parent,
|
|||
switch (format) {
|
||||
case GST_FORMAT_BYTES:
|
||||
peer_pos -= gst_adapter_available (typefind->adapter);
|
||||
if (peer_pos < 0) /* Clamp result to 0 */
|
||||
peer_pos = 0;
|
||||
break;
|
||||
default:
|
||||
/* FIXME */
|
||||
|
|
Loading…
Reference in a new issue