mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-20 07:16:55 +00:00
queue2: avoid crashing due to negative percent
queue2 would crash when using small buffer sizes because it would overflow when calculating the percentage, resulting in the buffering GstMessage not being created and trying to be used. This patch uses a gint64 instead of a gint to do the percentage math, making it harder to overflow.
This commit is contained in:
parent
5c7104c002
commit
245089c9bd
1 changed files with 3 additions and 2 deletions
|
@ -580,7 +580,7 @@ apply_buffer (GstQueue2 * queue, GstBuffer * buffer, GstSegment * segment)
|
||||||
static void
|
static void
|
||||||
update_buffering (GstQueue2 * queue)
|
update_buffering (GstQueue2 * queue)
|
||||||
{
|
{
|
||||||
gint percent;
|
gint64 percent;
|
||||||
gboolean post = FALSE;
|
gboolean post = FALSE;
|
||||||
|
|
||||||
if (!queue->use_buffering || queue->high_percent <= 0)
|
if (!queue->use_buffering || queue->high_percent <= 0)
|
||||||
|
@ -647,7 +647,8 @@ update_buffering (GstQueue2 * queue)
|
||||||
}
|
}
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (queue, "buffering %d percent", percent);
|
GST_DEBUG_OBJECT (queue, "buffering %d percent", percent);
|
||||||
message = gst_message_new_buffering (GST_OBJECT_CAST (queue), percent);
|
message = gst_message_new_buffering (GST_OBJECT_CAST (queue),
|
||||||
|
(gint) percent);
|
||||||
gst_message_set_buffering_stats (message, mode,
|
gst_message_set_buffering_stats (message, mode,
|
||||||
queue->byte_in_rate, queue->byte_out_rate, buffering_left);
|
queue->byte_in_rate, queue->byte_out_rate, buffering_left);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue