[vlc-devel] [PATCH 4/8] sout_access/core: handle drain

Thomas Guillem thomas at gllm.fr
Mon Jan 29 18:25:52 CET 2018


Just 2 modules didn't handle the buffer NULL case.
Draining implementation on specific modules will come with future commits.
---
 include/vlc_sout.h            | 3 ++-
 modules/access_output/dummy.c | 3 ++-
 modules/access_output/srt.c   | 2 +-
 3 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/include/vlc_sout.h b/include/vlc_sout.h
index 1ce1cc006b..bcf412b516 100644
--- a/include/vlc_sout.h
+++ b/include/vlc_sout.h
@@ -81,7 +81,8 @@ struct sout_access_out_t
     sout_access_out_sys_t   *p_sys;
     int                     (*pf_seek)( sout_access_out_t *, off_t );
     ssize_t                 (*pf_read)( sout_access_out_t *, block_t * );
-    ssize_t                 (*pf_write)( sout_access_out_t *, block_t * );
+    /* Write a block. If p_block is NULL, the module should drain itsef. */
+    ssize_t                 (*pf_write)( sout_access_out_t *, block_t *p_block );
     int                     (*pf_control)( sout_access_out_t *, int, va_list );
 
     config_chain_t          *p_cfg;
diff --git a/modules/access_output/dummy.c b/modules/access_output/dummy.c
index d7aa646265..4e93b9fca4 100644
--- a/modules/access_output/dummy.c
+++ b/modules/access_output/dummy.c
@@ -82,7 +82,8 @@ static ssize_t Write( sout_access_out_t *p_access, block_t *p_buffer )
         b = b->p_next;
     }
 
-    block_ChainRelease( p_buffer );
+    if( p_buffer )
+        block_ChainRelease( p_buffer );
 
     (void)p_access;
     return i_write;
diff --git a/modules/access_output/srt.c b/modules/access_output/srt.c
index 904d8f56d0..c616f3dcba 100644
--- a/modules/access_output/srt.c
+++ b/modules/access_output/srt.c
@@ -137,7 +137,7 @@ retry:
 
 out:
     vlc_interrupt_unregister();
-    if ( i_len <= 0 ) block_ChainRelease( p_buffer );
+    if ( i_len <= 0 && p_buffer ) block_ChainRelease( p_buffer );
     return i_len;
 }
 
-- 
2.11.0



More information about the vlc-devel mailing list