[vlc-devel] [PATCH] stream_filter/cache_block: fix premature EOF

Filip Roséen filip at videolabs.io
Sat Jun 4 14:58:53 CEST 2016

AStreamReadBlock would potentially return 0 because the current data block
(denoted by "p_sys->p_current") was exhausted, even though there might be more
data in the next data block ("p_sys->p_current->p_next").

This patch fixes the issue by calling the function one more time if this is the
case. Given the check for EOF in the beginning of the function, it will abort
correctly if we are /really/ out of data.


At the place where this patch apply, `p_sys->p_current` has been set to
`p_sys->p_current->p_next`, so the pointer denotes the next block to
process (even though the name is rather misleading at that point).

 modules/stream_filter/cache_block.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/modules/stream_filter/cache_block.c b/modules/stream_filter/cache_block.c
index dc31506..7695fac 100644
--- a/modules/stream_filter/cache_block.c
+++ b/modules/stream_filter/cache_block.c
@@ -402,6 +402,16 @@ static ssize_t AStreamReadBlock(stream_t *s, void *buf, size_t len)
+    /**
+     * we should not signal end-of-file if we have not exhausted
+     * the blocks we know about, as such we should try again if that
+     * is the case. i_copy == 0 just means that the processed block does
+     * not contain data at the offset that we want, not EOF.
+     **/
+    if( i_copy == 0 && sys->p_current )
+        return AStreamReadBlock( s, buf, len );
     sys->i_pos += i_copy;
     return i_copy;

More information about the vlc-devel mailing list