[vlc-devel] [PATCH] input/stream: do not unconditionally invalidate block on seek
Filip Roséen
filip at atch.se
Mon Oct 24 02:13:11 CEST 2016
If a seek request happens to refer to a position within the already
read block, simply update the block so that it refers to the desired
data.
There is really no need for us to discard the block, only to ask the
underlying stream to give us a new one (when we have the data we want
already).
---
src/input/stream.c | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/src/input/stream.c b/src/input/stream.c
index 6c614f8..a2ef6b6 100644
--- a/src/input/stream.c
+++ b/src/input/stream.c
@@ -576,6 +576,20 @@ int vlc_stream_Seek(stream_t *s, uint64_t offset)
return VLC_SUCCESS; /* Nothing to do! */
}
+ if( priv->block &&
+ priv->offset < offset &&
+ priv->offset + priv->block->i_buffer > offset )
+ {
+ /* seeking within current block */
+ size_t skipped = offset - priv->offset;
+
+ priv->block->p_buffer += skipped;
+ priv->block->i_buffer -= skipped;
+ priv->offset = offset;
+
+ return VLC_SUCCESS;
+ }
+
if (s->pf_seek == NULL)
return VLC_EGENERIC;
--
2.10.0
More information about the vlc-devel
mailing list