- input_thread_t *p_input = p_owner->p_input;
- vout_thread_t *p_vout;
- subpicture_t *p_spu;
-
- while( (p_spu = p_dec->pf_decode_sub( p_dec, p_block ? &p_block : NULL ) ) )
- {
- if( p_input != NULL )
- {
- vlc_mutex_lock( &p_input->p->counters.counters_lock );
- stats_Update( p_input->p->counters.p_decoded_sub, 1, NULL );
- vlc_mutex_unlock( &p_input->p->counters.counters_lock );
- }
-
- p_vout = input_resource_HoldVout( p_owner->p_resource );
- if( p_vout && p_owner->p_spu_vout == p_vout )
- {
- /* Preroll does not work very well with subtitle */
- if( p_spu->i_start > VLC_TS_INVALID &&
- p_spu->i_start < p_owner->i_preroll_end &&
- ( p_spu->i_stop <= VLC_TS_INVALID || p_spu->i_stop < p_owner->i_preroll_end ) )
- {
- subpicture_Delete( p_spu );
- }
- else
- {
- DecoderPlaySpu( p_dec, p_spu );
- }
- }
- else
- {
- subpicture_Delete( p_spu );
- }
- if( p_vout )
- vlc_object_release( p_vout );
- }
-
- if( b_flush && p_owner->p_spu_vout )
- {
- p_vout = input_resource_HoldVout( p_owner->p_resource );
-
- if( p_vout && p_owner->p_spu_vout == p_vout )
- vout_FlushSubpictureChannel( p_vout, p_owner->i_spu_channel );
-
- if( p_vout )
- vlc_object_release( p_vout );
- }
-}
-
-/* */
-static void DecoderProcessOnFlush( decoder_t *p_dec )
-{
- decoder_owner_sys_t *p_owner = p_dec->p_owner;
-
- vlc_mutex_lock( &p_owner->lock );
- DecoderFlushBuffering( p_dec );
-
- if( p_owner->b_flushing )
- {
- p_owner->b_flushing = false;
- vlc_cond_signal( &p_owner->wait_acknowledge );
- }
- vlc_mutex_unlock( &p_owner->lock );
-}
-
-/**
- * Decode a block
- *
- * \param p_dec the decoder object
- * \param p_block the block to decode
- * \return VLC_SUCCESS or an error code
- */
-static void DecoderProcess( decoder_t *p_dec, block_t *p_block )
-{
- decoder_owner_sys_t *p_owner = (decoder_owner_sys_t *)p_dec->p_owner;
- const bool b_flush_request = p_block && (p_block->i_flags & BLOCK_FLAG_CORE_FLUSH);
-
- if( p_block && p_block->i_buffer <= 0 )
- {
- assert( !b_flush_request );
- block_Release( p_block );
- return;
- }
-
-#ifdef ENABLE_SOUT
- if( p_owner->b_packetizer )
- {
- if( p_block )
- p_block->i_flags &= ~BLOCK_FLAG_CORE_PRIVATE_MASK;
-
- DecoderProcessSout( p_dec, p_block );
- }
- else
-#endif
- {
- bool b_flush = false;
-
- if( p_block )
- {
- const bool b_flushing = p_owner->i_preroll_end == INT64_MAX;
- DecoderUpdatePreroll( &p_owner->i_preroll_end, p_block );
-
- b_flush = !b_flushing && b_flush_request;
-
- p_block->i_flags &= ~BLOCK_FLAG_CORE_PRIVATE_MASK;
- }
-
- if( p_dec->fmt_out.i_cat == AUDIO_ES )
- {
- DecoderProcessAudio( p_dec, p_block, b_flush );
- }
- else if( p_dec->fmt_out.i_cat == VIDEO_ES )
- {
- DecoderProcessVideo( p_dec, p_block, b_flush );
- }
- else if( p_dec->fmt_out.i_cat == SPU_ES )
- {
- DecoderProcessSpu( p_dec, p_block, b_flush );
- }
- else
- {
- msg_Err( p_dec, "unknown ES format" );
- p_dec->b_error = true;
- }
- }
-
- /* */
- if( b_flush_request )
- DecoderProcessOnFlush( p_dec );
-}
-
-static void DecoderError( decoder_t *p_dec, block_t *p_block )
-{
- const bool b_flush_request = p_block && (p_block->i_flags & BLOCK_FLAG_CORE_FLUSH);
-
- /* */
- if( p_block )
- block_Release( p_block );
-
- if( b_flush_request )
- DecoderProcessOnFlush( p_dec );
-}
-
-
-/**
- * Destroys a decoder object
- *
- * \param p_dec the decoder object
- * \return nothing
- */
-static void DeleteDecoder( decoder_t * p_dec )
-{
- decoder_owner_sys_t *p_owner = p_dec->p_owner;
-
- msg_Dbg( p_dec, "killing decoder fourcc `%4.4s', %u PES in FIFO",
- (char*)&p_dec->fmt_in.i_codec,
- (unsigned)block_FifoCount( p_owner->p_fifo ) );