[vlc-devel] [PATCH] decoder: process the last block when closing

Rafaël Carré rafael.carre at gmail.com
Tue Jul 19 04:26:04 CEST 2011


There might be a buffer still stored in packetizer buffers

refs: #3178
---
 src/input/decoder.c          |   10 +++++++++-
 src/input/decoder.h          |    1 +
 src/input/es_out.c           |    8 ++++++++
 src/input/es_out_timeshift.c |    7 +++----
 4 files changed, 21 insertions(+), 5 deletions(-)

diff --git a/src/input/decoder.c b/src/input/decoder.c
index bf09978..ac3124c 100644
--- a/src/input/decoder.c
+++ b/src/input/decoder.c
@@ -922,13 +922,21 @@ static void *DecoderThread( void *p_data )
     /* The decoder's main loop */
     for( ;; )
     {
+        bool eos = false;
         block_t *p_block = block_FifoGet( p_owner->p_fifo );
 
         /* Make sure there is no cancellation point other than this one^^.
          * If you need one, be sure to push cleanup of p_block. */
         DecoderSignalBuffering( p_dec, p_block == NULL );
 
-        if( p_block )
+        if( p_block->i_flags & BLOCK_FLAG_EOS )
+        {
+            eos = true;
+            block_Release( p_block );
+            p_block = NULL;
+        }
+
+        if( p_block || eos )
         {
             int canc = vlc_savecancel();
 
diff --git a/src/input/decoder.h b/src/input/decoder.h
index 435afdc..b16b61f 100644
--- a/src/input/decoder.h
+++ b/src/input/decoder.h
@@ -29,6 +29,7 @@
 #include <vlc_codec.h>
 
 #define BLOCK_FLAG_CORE_FLUSH (1 <<BLOCK_FLAG_CORE_PRIVATE_SHIFT)
+#define BLOCK_FLAG_EOS        (1 <<(BLOCK_FLAG_CORE_PRIVATE_SHIFT + 1))
 
 decoder_t *input_DecoderNew( input_thread_t *, es_format_t *, input_clock_t *,
                              sout_instance_t * ) VLC_USED;
diff --git a/src/input/es_out.c b/src/input/es_out.c
index fb9c289..b0a5449 100644
--- a/src/input/es_out.c
+++ b/src/input/es_out.c
@@ -1924,6 +1924,14 @@ static int EsOutSend( es_out_t *out, es_out_id_t *es, block_t *p_block )
     input_thread_t *p_input = p_sys->p_input;
     int i_total = 0;
 
+    if( !p_block )
+    {
+        p_block = block_Alloc(0);
+        if( !p_block )
+            return VLC_ENOMEM;
+        p_block->i_flags |= BLOCK_FLAG_EOS;
+    }
+
     if( libvlc_stats( p_input ) )
     {
         vlc_mutex_lock( &p_input->p->counters.counters_lock );
diff --git a/src/input/es_out_timeshift.c b/src/input/es_out_timeshift.c
index d2d9b43..2930736 100644
--- a/src/input/es_out_timeshift.c
+++ b/src/input/es_out_timeshift.c
@@ -1269,12 +1269,11 @@ static int CmdExecuteSend( es_out_t *p_out, ts_cmd_t *p_cmd )
 
     p_cmd->u.send.p_block = NULL;
 
+    if( p_cmd->u.send.p_es->p_es )
+        return es_out_Send( p_out, p_cmd->u.send.p_es->p_es, p_block );
     if( p_block )
-    {
-        if( p_cmd->u.send.p_es->p_es )
-            return es_out_Send( p_out, p_cmd->u.send.p_es->p_es, p_block );
         block_Release( p_block );
-    }
+
     return VLC_EGENERIC;
 }
 static void CmdCleanSend( ts_cmd_t *p_cmd )
-- 
1.7.4.1





More information about the vlc-devel mailing list