[vlc-commits] cache_block: fix regression on not refilling cache on read

Ilkka Ollakka git at videolan.org
Thu May 3 15:11:21 CEST 2018


vlc | branch: master | Ilkka Ollakka <ileoo at videolan.org> | Sat Apr 21 12:32:22 2018 +0300| [355ce920644185e0a1f418b8b6258aade128db93] | committer: Ilkka Ollakka

cache_block: fix regression on not refilling cache on read

Regression from 9a725a039d8cfcf91aabad0101da1563a627493f.

Tested by disabling pf_block-check in cache_block and renaming
cache_read shortcut to cachexxx. Tip from Remi. Passes all make checks.

ref #20306

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=355ce920644185e0a1f418b8b6258aade128db93
---

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

diff --git a/modules/stream_filter/cache_block.c b/modules/stream_filter/cache_block.c
index 313cc45334..4c02fe7c99 100644
--- a/modules/stream_filter/cache_block.c
+++ b/modules/stream_filter/cache_block.c
@@ -184,24 +184,28 @@ static ssize_t AStreamReadBlock(stream_t *s, void *buf, size_t len)
 {
     stream_sys_t *sys = s->p_sys;
 
-    /* It means EOF */
-    if (sys->cache.p_chain== NULL)
-        return 0;
-
     ssize_t i_current = block_BytestreamRemaining( &sys->cache );
     size_t i_copy = VLC_CLIP((size_t)i_current, 0, len);
 
-    /* Copy data */
-    if( block_GetBytes( &sys->cache, buf, i_copy ) )
-        return -1;
-
     /**
      * 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
+     * the cache. i_copy == 0 just means that the cache currently does
      * not contain data at the offset that we want, not EOF.
      **/
+    if( i_copy == 0 )
+    {
+        /* Return EOF if we are unable to refill cache, most likely
+         * really EOF */
+        if( AStreamRefillBlock(s) == VLC_EGENERIC )
+            return 0;
+    }
+
+    /* Copy data */
+    if( block_GetBytes( &sys->cache, buf, i_copy ) )
+        return -1;
+
 
+    /* If we ended up on refill, try to read refilled cache */
     if( i_copy == 0 && sys->cache.p_chain )
         return AStreamReadBlock( s, buf, len );
 



More information about the vlc-commits mailing list