[vlc-devel] [PATCH 1/3] decoder: process the last block when closing
Laurent Aimar
fenrir at elivagar.org
Tue Aug 2 21:32:25 CEST 2011
On Mon, Aug 01, 2011 at 11:17:36PM -0400, Rafaël Carré wrote:
> 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 | 14 ++++++++++++++
> src/input/input.c | 1 +
> src/input/input_internal.h | 2 ++
> 5 files changed, 27 insertions(+), 1 deletions(-)
>
> diff --git a/src/input/decoder.c b/src/input/decoder.c
> index 992ec9f..9f80efe 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 && 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 6f2dcb2..8c93dc3 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))
As it's internal, I would prefer if you used BLOCK_FLAG_CORE_ as prefix.
> 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 1bb92bc..3248d42 100644
> --- a/src/input/es_out.c
> +++ b/src/input/es_out.c
> @@ -3020,3 +3020,17 @@ static void EsOutUpdateInfo( es_out_t *out, es_out_id_t *es, const es_format_t *
> input_Control( p_input, INPUT_REPLACE_INFOS, p_cat );
> }
>
> +void EsOutEOS(es_out_t *out)
> +{
> + es_out_sys_t *p_sys = out->p_sys;
> + for (int i = 0; i < p_sys->i_es; i++) {
> + es_out_id_t *id = p_sys->es[i];
> + decoder_t *p_dec = id->p_dec;
p_dec can be NULL and you have locking issue (but it should probably be
automatically fixed when you implement it as advised below.
> + block_t *p_block = block_Alloc(0);
> + if( !p_block )
> + return;
> +
> + p_block->i_flags |= BLOCK_FLAG_EOS;
> + input_DecoderDecode(p_dec, p_block, false);
> + }
> +}
> diff --git a/src/input/input.c b/src/input/input.c
> index 7927480..efab1b4 100644
> --- a/src/input/input.c
> +++ b/src/input/input.c
> @@ -617,6 +617,7 @@ static void MainLoopDemux( input_thread_t *p_input, bool *pb_changed, bool *pb_d
> {
> msg_Dbg( p_input, "EOF reached" );
> p_input->p->input.b_eof = true;
> + EsOutEOS(p_input->p->p_es_out_display);
Now, you will have to send this order through p_input->p->p_es_out
which mean you need to let it pass through es_out_timeshift.
For that you can look at how ES_OUT_SET_TIMES/es_out_SetTimes are
implemented.
> }
> else if( i_ret < 0 )
> {
> diff --git a/src/input/input_internal.h b/src/input/input_internal.h
> index fc787cd..11ab8ce 100644
> --- a/src/input/input_internal.h
> +++ b/src/input/input_internal.h
> @@ -243,4 +243,6 @@ void input_ConfigVarInit ( input_thread_t * );
> char **subtitles_Detect( input_thread_t *, char* path, const char *fname );
> int subtitles_Filter( const char *);
>
> +void EsOutEOS(es_out_t *);
> +
> #endif
> --
> 1.7.5.4
>
>
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> http://mailman.videolan.org/listinfo/vlc-devel
--
--
() Laurent Aimar <fenrir at videolan.org>
__( )__ Developer of VideoLAN - www.videolan.org
| ( `´ ) | The video streaming solution for Linux, Windows, MacOSX...
| `--´ | " Life is a cone "
````````
More information about the vlc-devel
mailing list