mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-19 14:56:36 +00:00
queue2: avoid waiting for a filled buffer
Use a threshold variable to hold the maximum distance from the current position for with we will wait instead of doing a seek. When using the ringbuffer and the requested offset is not available, avoid waiting until the complete ringbuffer is filled but instead do a seek when the requested data is further than the threshold. Avoid doing the seek twice in the ringbuffer case. Use the same threshold for ringbuffer and download buffering.
This commit is contained in:
parent
4d79cbe7ef
commit
0bb0c68566
1 changed files with 16 additions and 9 deletions
|
@ -1139,20 +1139,27 @@ gst_queue2_have_data (GstQueue2 * queue, guint64 offset, guint length)
|
||||||
(offset + length) - range->writing_pos);
|
(offset + length) - range->writing_pos);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
GST_INFO_OBJECT (queue, "not found in any range");
|
GST_INFO_OBJECT (queue, "not found in any range off %" G_GUINT64_FORMAT
|
||||||
/* we don't have the range, see how far away we are, FIXME, find a good
|
" len %u", offset, length);
|
||||||
* threshold based on the incoming rate. */
|
/* we don't have the range, see how far away we are */
|
||||||
if (!queue->is_eos && queue->current) {
|
if (!queue->is_eos && queue->current) {
|
||||||
|
/* FIXME, find a good threshold based on the incoming rate. */
|
||||||
|
guint64 threshold = 1024 * 512;
|
||||||
|
|
||||||
if (QUEUE_IS_USING_RING_BUFFER (queue)) {
|
if (QUEUE_IS_USING_RING_BUFFER (queue)) {
|
||||||
if (offset < queue->current->offset || offset >
|
guint64 distance;
|
||||||
queue->current->writing_pos + QUEUE_MAX_BYTES (queue) -
|
|
||||||
queue->cur_level.bytes) {
|
distance = QUEUE_MAX_BYTES (queue) - queue->cur_level.bytes;
|
||||||
perform_seek_to_offset (queue, offset);
|
/* don't wait for the complete buffer to fill */
|
||||||
} else {
|
distance = MIN (distance, threshold);
|
||||||
|
|
||||||
|
if (offset >= queue->current->offset && offset <=
|
||||||
|
queue->current->writing_pos + distance) {
|
||||||
GST_INFO_OBJECT (queue,
|
GST_INFO_OBJECT (queue,
|
||||||
"requested data is within range, wait for data");
|
"requested data is within range, wait for data");
|
||||||
|
return FALSE;
|
||||||
}
|
}
|
||||||
} else if (offset < queue->current->writing_pos + 200000) {
|
} else if (offset < queue->current->writing_pos + threshold) {
|
||||||
update_cur_pos (queue, queue->current, offset + length);
|
update_cur_pos (queue, queue->current, offset + length);
|
||||||
GST_INFO_OBJECT (queue, "wait for data");
|
GST_INFO_OBJECT (queue, "wait for data");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
Loading…
Reference in a new issue