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

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


There might be a buffer still stored in packetizer buffers

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

diff --git a/src/input/decoder.c b/src/input/decoder.c
index bf09978..63b9c13 100644
--- a/src/input/decoder.c
+++ b/src/input/decoder.c
@@ -928,18 +928,21 @@ static void *DecoderThread( void *p_data )
          * 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 )
         {
-            int canc = vlc_savecancel();
+            block_Release( p_block );
+            p_block = NULL;
+        }
 
-            if( p_dec->b_error )
-                DecoderError( p_dec, p_block );
-            else
-                DecoderProcess( p_dec, p_block );
+        int canc = vlc_savecancel();
 
-            vlc_restorecancel( canc );
-        }
-    }
+        if( p_dec->b_error )
+            DecoderError( p_dec, p_block );
+        else
+            DecoderProcess( p_dec, p_block );
+
+        vlc_restorecancel( canc );
+}
     return NULL;
 }
 
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