[vlc-devel] [PATCH 02/13] decoder: add _internal to internal calls to differentiate from public APIs
Thomas Guillem
thomas at gllm.fr
Mon Sep 2 16:51:38 CEST 2019
On Mon, Sep 2, 2019, at 16:22, Steve Lhomme wrote:
> Personally I don't like this patch very much. It's less readable IMO.
> Having the owner as input you already know it can't be called from outside.
Me neither, you can drop it.
>
> On 2019-09-02 16:20, Steve Lhomme wrote:
> > ---
> > src/input/decoder.c | 108 ++++++++++++++++++++++----------------------
> > 1 file changed, 54 insertions(+), 54 deletions(-)
> >
> > diff --git a/src/input/decoder.c b/src/input/decoder.c
> > index 1e21698c5c..533351e63e 100644
> > --- a/src/input/decoder.c
> > +++ b/src/input/decoder.c
> > @@ -197,7 +197,7 @@ static int LoadDecoder( decoder_t *p_dec, bool b_packetizer,
> > return 0;
> > }
> >
> > -static int ReloadDecoder( struct decoder_owner *p_owner, bool b_packetizer,
> > +static int ReloadDecoder_internal( struct decoder_owner *p_owner, bool b_packetizer,
> > const es_format_t *restrict p_fmt, enum reload reload )
> > {
> > /* Copy p_fmt since it can be destroyed by decoder_Clean */
> > @@ -238,7 +238,7 @@ static int ReloadDecoder( struct decoder_owner *p_owner, bool b_packetizer,
> > return VLC_SUCCESS;
> > }
> >
> > -static void DecoderUpdateFormatLocked( struct decoder_owner *p_owner )
> > +static void DecoderUpdateFormatLocked_internal( struct decoder_owner *p_owner )
> > {
> > decoder_t *p_dec = &p_owner->dec;
> >
> > @@ -358,7 +358,7 @@ static int aout_update_format( decoder_t *p_dec )
> > vlc_mutex_lock( &p_owner->lock );
> > p_owner->p_aout = p_aout;
> >
> > - DecoderUpdateFormatLocked( p_owner );
> > + DecoderUpdateFormatLocked_internal( p_owner );
> > aout_FormatPrepare( &p_owner->fmt.audio );
> > vlc_mutex_unlock( &p_owner->lock );
> >
> > @@ -553,7 +553,7 @@ static int vout_update_format( decoder_t *p_dec )
> > vlc_mutex_lock( &p_owner->lock );
> > p_owner->p_vout = p_vout;
> >
> > - DecoderUpdateFormatLocked( p_owner );
> > + DecoderUpdateFormatLocked_internal( p_owner );
> > p_owner->fmt.video.i_chroma = p_dec->fmt_out.i_codec;
> > vlc_mutex_unlock( &p_owner->lock );
> >
> > @@ -572,7 +572,7 @@ static int vout_update_format( decoder_t *p_dec )
> > {
> > /* the format has changed but we don't need a new vout */
> > vlc_mutex_lock( &p_owner->lock );
> > - DecoderUpdateFormatLocked( p_owner );
> > + DecoderUpdateFormatLocked_internal( p_owner );
> > vlc_mutex_unlock( &p_owner->lock );
> > }
> > return 0;
> > @@ -741,7 +741,7 @@ block_t *decoder_NewAudioBuffer( decoder_t *dec, int samples )
> > return block;
> > }
> >
> > -static void RequestReload( struct decoder_owner *p_owner )
> > +static void RequestReload_internal( struct decoder_owner *p_owner )
> > {
> > /* Don't override reload if it's RELOAD_DECODER_AOUT */
> > int expected = RELOAD_NO_REQUEST;
> > @@ -758,7 +758,7 @@ void decoder_AbortPictures( decoder_t *p_dec, bool b_abort )
> > vlc_mutex_unlock( &p_owner->lock );
> > }
> >
> > -static void DecoderWaitUnblock( struct decoder_owner *p_owner )
> > +static void DecoderWaitUnblock_internal( struct decoder_owner *p_owner )
> > {
> > vlc_mutex_assert( &p_owner->lock );
> >
> > @@ -785,7 +785,7 @@ static inline void DecoderUpdatePreroll( vlc_tick_t *pi_preroll, const block_t *
> > }
> >
> > #ifdef ENABLE_SOUT
> > -static int DecoderPlaySout( struct decoder_owner *p_owner, block_t *p_sout_block )
> > +static int DecoderPlaySout_internal( struct decoder_owner *p_owner, block_t *p_sout_block )
> > {
> > assert( !p_sout_block->p_next );
> >
> > @@ -797,7 +797,7 @@ static int DecoderPlaySout( struct decoder_owner *p_owner, block_t *p_sout_block
> > vlc_cond_signal( &p_owner->wait_acknowledge );
> > }
> >
> > - DecoderWaitUnblock( p_owner );
> > + DecoderWaitUnblock_internal( p_owner );
> >
> > vlc_mutex_unlock( &p_owner->lock );
> >
> > @@ -807,7 +807,7 @@ static int DecoderPlaySout( struct decoder_owner *p_owner, block_t *p_sout_block
> >
> > /* This function process a block for sout
> > */
> > -static void DecoderProcessSout( struct decoder_owner *p_owner, block_t *p_block )
> > +static void DecoderProcessSout_internal( struct decoder_owner *p_owner, block_t *p_block )
> > {
> > decoder_t *p_dec = &p_owner->dec;
> > block_t *p_sout_block;
> > @@ -819,7 +819,7 @@ static void DecoderProcessSout( struct decoder_owner *p_owner, block_t *p_block
> > if( p_owner->p_sout_input == NULL )
> > {
> > vlc_mutex_lock( &p_owner->lock );
> > - DecoderUpdateFormatLocked( p_owner );
> > + DecoderUpdateFormatLocked_internal( p_owner );
> >
> > p_owner->fmt.i_group = p_dec->fmt_in.i_group;
> > p_owner->fmt.i_id = p_dec->fmt_in.i_id;
> > @@ -883,7 +883,7 @@ static void DecoderProcessSout( struct decoder_owner *p_owner, block_t *p_block
> > }
> > }
> >
> > - if( DecoderPlaySout( p_owner, p_sout_block ) == VLC_EGENERIC )
> > + if( DecoderPlaySout_internal( p_owner, p_sout_block ) == VLC_EGENERIC )
> > {
> > msg_Err( p_dec, "cannot continue streaming due to errors with codec %4.4s",
> > (char *)&p_owner->fmt.i_codec );
> > @@ -905,7 +905,7 @@ static void DecoderProcessSout( struct decoder_owner *p_owner, block_t *p_block
> > }
> > #endif
> >
> > -static void DecoderPlayCc( struct decoder_owner *p_owner, block_t *p_cc,
> > +static void DecoderPlayCc_internal( struct decoder_owner *p_owner, block_t *p_cc,
> > const decoder_cc_desc_t *p_desc )
> > {
> > vlc_mutex_lock( &p_owner->lock );
> > @@ -941,7 +941,7 @@ static void DecoderPlayCc( struct decoder_owner *p_owner, block_t *p_cc,
> > block_Release( p_cc );
> > }
> >
> > -static void PacketizerGetCc( struct decoder_owner *p_owner, decoder_t *p_dec_cc )
> > +static void PacketizerGetCc_internal( struct decoder_owner *p_owner, decoder_t *p_dec_cc )
> > {
> > block_t *p_cc;
> > decoder_cc_desc_t desc;
> > @@ -955,7 +955,7 @@ static void PacketizerGetCc( struct decoder_owner *p_owner, decoder_t *p_dec_cc
> > p_cc = p_dec_cc->pf_get_cc( p_dec_cc, &desc );
> > if( !p_cc )
> > return;
> > - DecoderPlayCc( p_owner, p_cc, &desc );
> > + DecoderPlayCc_internal( p_owner, p_cc, &desc );
> > }
> >
> > static void DecoderQueueCc( decoder_t *p_videodec, block_t *p_cc,
> > @@ -967,13 +967,13 @@ static void DecoderQueueCc( decoder_t *p_videodec, block_t *p_cc,
> > {
> > if( p_owner->cc.b_supported &&
> > ( !p_owner->p_packetizer || !p_owner->p_packetizer->pf_get_cc ) )
> > - DecoderPlayCc( p_owner, p_cc, p_desc );
> > + DecoderPlayCc_internal( p_owner, p_cc, p_desc );
> > else
> > block_Release( p_cc );
> > }
> > }
> >
> > -static void DecoderPlayVideo( struct decoder_owner *p_owner, picture_t *p_picture,
> > +static void DecoderPlayVideo_internal( struct decoder_owner *p_owner, picture_t *p_picture,
> > unsigned *restrict pi_lost_sum )
> > {
> > decoder_t *p_dec = &p_owner->dec;
> > @@ -1015,7 +1015,7 @@ static void DecoderPlayVideo( struct decoder_owner *p_owner, picture_t *p_pictur
> > vlc_cond_signal( &p_owner->wait_acknowledge );
> > }
> >
> > - DecoderWaitUnblock( p_owner );
> > + DecoderWaitUnblock_internal( p_owner );
> >
> > if( p_owner->b_waiting )
> > {
> > @@ -1087,7 +1087,7 @@ static void DecoderQueueVideo( decoder_t *p_dec, picture_t *p_pic )
> > unsigned i_lost = 0;
> > struct decoder_owner *p_owner = dec_get_owner( p_dec );
> >
> > - DecoderPlayVideo( p_owner, p_pic, &i_lost );
> > + DecoderPlayVideo_internal( p_owner, p_pic, &i_lost );
> >
> > p_owner->pf_update_stat( p_owner, 1, i_lost );
> > }
> > @@ -1120,7 +1120,7 @@ static void DecoderQueueThumbnail( decoder_t *p_dec, picture_t *p_pic )
> >
> > }
> >
> > -static void DecoderPlayAudio( struct decoder_owner *p_owner, block_t *p_audio,
> > +static void DecoderPlayAudio_internal( struct decoder_owner *p_owner, block_t *p_audio,
> > unsigned *restrict pi_lost_sum )
> > {
> > decoder_t *p_dec = &p_owner->dec;
> > @@ -1166,7 +1166,7 @@ static void DecoderPlayAudio( struct decoder_owner *p_owner, block_t *p_audio,
> > }
> >
> > /* */
> > - DecoderWaitUnblock( p_owner );
> > + DecoderWaitUnblock_internal( p_owner );
> > vlc_mutex_unlock( &p_owner->lock );
> >
> > audio_output_t *p_aout = p_owner->p_aout;
> > @@ -1177,7 +1177,7 @@ static void DecoderPlayAudio( struct decoder_owner *p_owner, block_t *p_audio,
> > if( status == AOUT_DEC_CHANGED )
> > {
> > /* Only reload the decoder */
> > - RequestReload( p_owner );
> > + RequestReload_internal( p_owner );
> > }
> > else if( status == AOUT_DEC_FAILED )
> > {
> > @@ -1217,12 +1217,12 @@ static void DecoderQueueAudio( decoder_t *p_dec, block_t *p_aout_buf )
> > unsigned lost = 0;
> > struct decoder_owner *p_owner = dec_get_owner( p_dec );
> >
> > - DecoderPlayAudio( p_owner, p_aout_buf, &lost );
> > + DecoderPlayAudio_internal( p_owner, p_aout_buf, &lost );
> >
> > p_owner->pf_update_stat( p_owner, 1, lost );
> > }
> >
> > -static void DecoderPlaySpu( struct decoder_owner *p_owner, subpicture_t *p_subpic )
> > +static void DecoderPlaySpu_internal( struct decoder_owner *p_owner, subpicture_t *p_subpic )
> > {
> > decoder_t *p_dec = &p_owner->dec;
> > vout_thread_t *p_vout = p_owner->p_vout;
> > @@ -1244,7 +1244,7 @@ static void DecoderPlaySpu( struct decoder_owner *p_owner, subpicture_t *p_subpi
> > vlc_cond_signal( &p_owner->wait_acknowledge );
> > }
> >
> > - DecoderWaitUnblock( p_owner );
> > + DecoderWaitUnblock_internal( p_owner );
> > vlc_mutex_unlock( &p_owner->lock );
> >
> > if( p_subpic->i_start == VLC_TICK_INVALID )
> > @@ -1282,12 +1282,12 @@ static void DecoderQueueSpu( decoder_t *p_dec, subpicture_t *p_spu )
> > else
> > {
> > vlc_mutex_unlock( &p_owner->lock );
> > - DecoderPlaySpu( p_owner, p_spu );
> > + DecoderPlaySpu_internal( p_owner, p_spu );
> > }
> > }
> >
> > -static void DecoderProcess( struct decoder_owner *p_owner, block_t *p_block );
> > -static void DecoderDecode( struct decoder_owner *p_owner, block_t *p_block )
> > +static void DecoderProcess_internal( struct decoder_owner *p_owner, block_t *p_block );
> > +static void DecoderDecode_internal( struct decoder_owner *p_owner, block_t *p_block )
> > {
> > decoder_t *p_dec = &p_owner->dec;
> >
> > @@ -1301,13 +1301,13 @@ static void DecoderDecode( struct decoder_owner *p_owner, block_t *p_block )
> > p_owner->error = true;
> > break;
> > case VLCDEC_RELOAD:
> > - RequestReload( p_owner );
> > + RequestReload_internal( p_owner );
> > if( unlikely( p_block == NULL ) )
> > break;
> > if( !( p_block->i_flags & BLOCK_FLAG_CORE_PRIVATE_RELOADED ) )
> > {
> > p_block->i_flags |= BLOCK_FLAG_CORE_PRIVATE_RELOADED;
> > - DecoderProcess( p_owner, p_block );
> > + DecoderProcess_internal( p_owner, p_block );
> > }
> > else /* We prefer loosing this block than an infinite recursion */
> > block_Release( p_block );
> > @@ -1323,7 +1323,7 @@ static void DecoderDecode( struct decoder_owner *p_owner, block_t *p_block )
> > * \param p_dec the decoder object
> > * \param p_block the block to decode
> > */
> > -static void DecoderProcess( struct decoder_owner *p_owner, block_t *p_block )
> > +static void DecoderProcess_internal( struct decoder_owner *p_owner, block_t *p_block )
> > {
> > decoder_t *p_dec = &p_owner->dec;
> >
> > @@ -1331,7 +1331,7 @@ static void DecoderProcess( struct decoder_owner *p_owner, block_t *p_block )
> > goto error;
> >
> > /* Here, the atomic doesn't prevent to miss a reload request.
> > - * DecoderProcess() can still be called after the decoder module or the
> > + * DecoderProcess_internal() can still be called after the decoder module or the
> > * audio output requested a reload. This will only result in a drop of an
> > * input block or an output buffer. */
> > enum reload reload;
> > @@ -1340,7 +1340,7 @@ static void DecoderProcess( struct decoder_owner *p_owner, block_t *p_block )
> > msg_Warn( p_dec, "Reloading the decoder module%s",
> > reload == RELOAD_DECODER_AOUT ? " and the audio output" : "" );
> >
> > - if( ReloadDecoder( p_owner, false, &p_dec->fmt_in, reload ) != VLC_SUCCESS )
> > + if( ReloadDecoder_internal( p_owner, false, &p_dec->fmt_in, reload ) != VLC_SUCCESS )
> > goto error;
> > }
> >
> > @@ -1363,7 +1363,7 @@ static void DecoderProcess( struct decoder_owner *p_owner, block_t *p_block )
> > #ifdef ENABLE_SOUT
> > if( p_owner->p_sout != NULL )
> > {
> > - DecoderProcessSout( p_owner, p_block );
> > + DecoderProcessSout_internal( p_owner, p_block );
> > return;
> > }
> > #endif
> > @@ -1381,9 +1381,9 @@ static void DecoderProcess( struct decoder_owner *p_owner, block_t *p_block )
> > msg_Dbg( p_dec, "restarting module due to input format change");
> >
> > /* Drain the decoder module */
> > - DecoderDecode( p_owner, NULL );
> > + DecoderDecode_internal( p_owner, NULL );
> >
> > - if( ReloadDecoder( p_owner, false, &p_packetizer->fmt_out,
> > + if( ReloadDecoder_internal( p_owner, false, &p_packetizer->fmt_out,
> > RELOAD_DECODER ) != VLC_SUCCESS )
> > {
> > block_ChainRelease( p_packetized_block );
> > @@ -1392,14 +1392,14 @@ static void DecoderProcess( struct decoder_owner *p_owner, block_t *p_block )
> > }
> >
> > if( p_packetizer->pf_get_cc )
> > - PacketizerGetCc( p_owner, p_packetizer );
> > + PacketizerGetCc_internal( p_owner, p_packetizer );
> >
> > while( p_packetized_block )
> > {
> > block_t *p_next = p_packetized_block->p_next;
> > p_packetized_block->p_next = NULL;
> >
> > - DecoderDecode( p_owner, p_packetized_block );
> > + DecoderDecode_internal( p_owner, p_packetized_block );
> > if( p_owner->error )
> > {
> > block_ChainRelease( p_next );
> > @@ -1411,10 +1411,10 @@ static void DecoderProcess( struct decoder_owner *p_owner, block_t *p_block )
> > }
> > /* Drain the decoder after the packetizer is drained */
> > if( !pp_block )
> > - DecoderDecode( p_owner, NULL );
> > + DecoderDecode_internal( p_owner, NULL );
> > }
> > else
> > - DecoderDecode( p_owner, p_block );
> > + DecoderDecode_internal( p_owner, p_block );
> > return;
> >
> > error:
> > @@ -1422,7 +1422,7 @@ error:
> > block_Release( p_block );
> > }
> >
> > -static void DecoderProcessFlush( struct decoder_owner *p_owner )
> > +static void DecoderProcessFlush_internal( struct decoder_owner *p_owner )
> > {
> > decoder_t *p_dec = &p_owner->dec;
> > decoder_t *p_packetizer = p_owner->p_packetizer;
> > @@ -1477,7 +1477,7 @@ static void DecoderProcessFlush( struct decoder_owner *p_owner )
> > vlc_mutex_unlock( &p_owner->lock );
> > }
> >
> > -static void OutputChangePause( struct decoder_owner *p_owner, bool paused, vlc_tick_t date )
> > +static void OutputChangePause_internal( struct decoder_owner *p_owner, bool paused, vlc_tick_t date )
> > {
> > decoder_t *p_dec = &p_owner->dec;
> >
> > @@ -1499,7 +1499,7 @@ static void OutputChangePause( struct decoder_owner *p_owner, bool paused, vlc_t
> > }
> > }
> >
> > -static void OutputChangeRate( struct decoder_owner *p_owner, float rate )
> > +static void OutputChangeRate_internal( struct decoder_owner *p_owner, float rate )
> > {
> > decoder_t *p_dec = &p_owner->dec;
> >
> > @@ -1528,7 +1528,7 @@ static void OutputChangeRate( struct decoder_owner *p_owner, float rate )
> > p_owner->output_rate = rate;
> > }
> >
> > -static void OutputChangeDelay( struct decoder_owner *p_owner, vlc_tick_t delay )
> > +static void OutputChangeDelay_internal( struct decoder_owner *p_owner, vlc_tick_t delay )
> > {
> > decoder_t *p_dec = &p_owner->dec;
> >
> > @@ -1583,12 +1583,12 @@ static void *DecoderThread( void *p_data )
> > vlc_fifo_Unlock( p_owner->p_fifo );
> >
> > /* Flush the decoder (and the output) */
> > - DecoderProcessFlush( p_owner );
> > + DecoderProcessFlush_internal( p_owner );
> >
> > vlc_fifo_Lock( p_owner->p_fifo );
> > vlc_restorecancel( canc );
> >
> > - /* Reset flushing after DecoderProcess in case input_DecoderFlush
> > + /* Reset flushing after DecoderProcess_internal in case input_DecoderFlush
> > * is called again. This will avoid a second useless flush (but
> > * harmless). */
> > p_owner->flushing = false;
> > @@ -1597,7 +1597,7 @@ static void *DecoderThread( void *p_data )
> > }
> >
> > /* Reset the original pause/rate state when a new aout/vout is created:
> > - * this will trigger the OutputChangePause/OutputChangeRate code path
> > + * this will trigger the OutputChangePause_internal/OutputChangeRate_internal code path
> > * if needed. */
> > if( p_owner->reset_out_state )
> > {
> > @@ -1616,7 +1616,7 @@ static void *DecoderThread( void *p_data )
> > vlc_fifo_Unlock( p_owner->p_fifo );
> >
> > vlc_mutex_lock( &p_owner->lock );
> > - OutputChangePause( p_owner, paused, date );
> > + OutputChangePause_internal( p_owner, paused, date );
> > vlc_mutex_unlock( &p_owner->lock );
> >
> > vlc_restorecancel( canc );
> > @@ -1632,7 +1632,7 @@ static void *DecoderThread( void *p_data )
> > vlc_fifo_Unlock( p_owner->p_fifo );
> >
> > vlc_mutex_lock( &p_owner->lock );
> > - OutputChangeRate( p_owner, rate );
> > + OutputChangeRate_internal( p_owner, rate );
> > vlc_mutex_unlock( &p_owner->lock );
> >
> > vlc_restorecancel( canc );
> > @@ -1647,7 +1647,7 @@ static void *DecoderThread( void *p_data )
> > vlc_fifo_Unlock( p_owner->p_fifo );
> >
> > vlc_mutex_lock( &p_owner->lock );
> > - OutputChangeDelay( p_owner, delay );
> > + OutputChangeDelay_internal( p_owner, delay );
> > vlc_mutex_unlock( &p_owner->lock );
> >
> > vlc_restorecancel( canc );
> > @@ -1684,7 +1684,7 @@ static void *DecoderThread( void *p_data )
> > vlc_fifo_Unlock( p_owner->p_fifo );
> >
> > int canc = vlc_savecancel();
> > - DecoderProcess( p_owner, p_block );
> > + DecoderProcess_internal( p_owner, p_block );
> >
> > if( p_block == NULL && p_owner->dec.fmt_out.i_cat == AUDIO_ES )
> > { /* Draining: the decoder is drained and all decoded buffers are
> > @@ -2275,7 +2275,7 @@ void input_DecoderGetCcDesc( decoder_t *p_dec, decoder_cc_desc_t *p_desc )
> > vlc_mutex_unlock( &p_owner->lock );
> > }
> >
> > -static bool input_DecoderHasCCChanFlag( struct decoder_owner *p_owner,
> > +static bool DecoderHasCCChanFlag_internal( struct decoder_owner *p_owner,
> > vlc_fourcc_t codec, int i_channel )
> > {
> > int i_max_channels;
> > @@ -2303,7 +2303,7 @@ int input_DecoderSetCcState( decoder_t *p_dec, vlc_fourcc_t codec,
> >
> > //msg_Warn( p_dec, "input_DecoderSetCcState: %d @%x", b_decode, i_channel );
> >
> > - if( !input_DecoderHasCCChanFlag( p_owner, codec, i_channel ) )
> > + if( !DecoderHasCCChanFlag_internal( p_owner, codec, i_channel ) )
> > return VLC_EGENERIC;
> >
> > if( b_decode )
> > @@ -2358,7 +2358,7 @@ int input_DecoderGetCcState( decoder_t *p_dec, vlc_fourcc_t codec,
> > {
> > struct decoder_owner *p_owner = dec_get_owner( p_dec );
> >
> > - if( !input_DecoderHasCCChanFlag( p_owner, codec, i_channel ) )
> > + if( !DecoderHasCCChanFlag_internal( p_owner, codec, i_channel ) )
> > return VLC_EGENERIC;
> >
> > vlc_mutex_lock( &p_owner->lock );
> > --
> > 2.17.1
> >
> > _______________________________________________
> > vlc-devel mailing list
> > To unsubscribe or modify your subscription options:
> > https://mailman.videolan.org/listinfo/vlc-devel
> >
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel
More information about the vlc-devel
mailing list