[vlc-devel] [PATCH] decoder: prefix some internal functions with their calling thread

Steve Lhomme robux4 at ycbcr.xyz
Wed Sep 4 16:26:40 CEST 2019


On 2019-09-04 16:18, Thomas Guillem wrote:
> 
> 
> On Wed, Sep 4, 2019, at 16:16, Steve Lhomme wrote:
>> DecoderOutputThreads_ for the decoder output thread(s) which can be the
> 
> As I said, I prefer to use Output_ for those functions.

I like short names but in this case it doesn't carry much meaning. For 
example OutputChangeDelay() didn't carry enough meaning. It was not 
called from the "output" of the decoder, but within the DecoderThread.

>> DecoderThread for synchronous decoders and any thread otherwise (concurrent
>> calls are not allowed).
>>
>> DecoderThread_ for internal DecoderThread calls.
>> ---
>>   src/input/decoder.c | 112 ++++++++++++++++++++++----------------------
>>   1 file changed, 56 insertions(+), 56 deletions(-)
>>
>> diff --git a/src/input/decoder.c b/src/input/decoder.c
>> index ea0667b9a8a..78229fc3898 100644
>> --- a/src/input/decoder.c
>> +++ b/src/input/decoder.c
>> @@ -201,8 +201,8 @@ static int LoadDecoder( decoder_t *p_dec, bool b_packetizer,
>>       return 0;
>>   }
>>   
>> -static int ReloadDecoder( struct decoder_owner *p_owner, bool
>> b_packetizer,
>> -                          const es_format_t *restrict p_fmt, enum
>> reload reload )
>> +static int DecoderThread_Reload( 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 */
>>       decoder_t *p_dec = &p_owner->dec;
>> @@ -292,7 +292,7 @@ static bool aout_replaygain_changed( const
>> audio_replay_gain_t *a,
>>       return false;
>>   }
>>   
>> -static int aout_update_format( decoder_t *p_dec )
>> +static int DecoderOutputThreads_UpdateAudioFormat( decoder_t *p_dec )
>>   {
>>       struct decoder_owner *p_owner = dec_get_owner( p_dec );
>>   
>> @@ -384,7 +384,7 @@ static int aout_update_format( decoder_t *p_dec )
>>       return 0;
>>   }
>>   
>> -static int vout_update_format( decoder_t *p_dec )
>> +static int DecoderOutputThreads_UpdateVideoFormat( decoder_t *p_dec )
>>   {
>>       struct decoder_owner *p_owner = dec_get_owner( p_dec );
>>       bool need_vout = false;
>> @@ -582,7 +582,7 @@ static int vout_update_format( decoder_t *p_dec )
>>       return 0;
>>   }
>>   
>> -static picture_t *vout_new_buffer( decoder_t *p_dec )
>> +static picture_t *DecoderOutputThreads_NewVideoBuffer( decoder_t *p_dec )
>>   {
>>       struct decoder_owner *p_owner = dec_get_owner( p_dec );
>>       assert( p_owner->p_vout );
>> @@ -590,7 +590,7 @@ static picture_t *vout_new_buffer( decoder_t *p_dec )
>>       return vout_GetPicture( p_owner->p_vout );
>>   }
>>   
>> -static subpicture_t *spu_new_buffer( decoder_t *p_dec,
>> +static subpicture_t *DecoderOutputThreads_NewSpuBuffer( decoder_t
>> *p_dec,
>>                                        const subpicture_updater_t
>> *p_updater )
>>   {
>>       struct decoder_owner *p_owner = dec_get_owner( p_dec );
>> @@ -962,7 +962,7 @@ static void PacketizerGetCc( struct decoder_owner
>> *p_owner, decoder_t *p_dec_cc
>>       DecoderPlayCc( p_owner, p_cc, &desc );
>>   }
>>   
>> -static void DecoderQueueCc( decoder_t *p_videodec, block_t *p_cc,
>> +static void DecoderOutputThreads_QueueCc( decoder_t *p_videodec,
>> block_t *p_cc,
>>                              const decoder_cc_desc_t *p_desc )
>>   {
>>       struct decoder_owner *p_owner = dec_get_owner( p_videodec );
>> @@ -977,7 +977,7 @@ static void DecoderQueueCc( decoder_t *p_videodec,
>> block_t *p_cc,
>>       }
>>   }
>>   
>> -static int DecoderPlayVideo( struct decoder_owner *p_owner, picture_t
>> *p_picture )
>> +static int DecoderOutputThreads_PlayVideo( struct decoder_owner
>> *p_owner, picture_t *p_picture )
>>   {
>>       decoder_t *p_dec = &p_owner->dec;
>>       vout_thread_t  *p_vout = p_owner->p_vout;
>> @@ -1051,8 +1051,8 @@ static int DecoderPlayVideo( struct decoder_owner
>> *p_owner, picture_t *p_picture
>>       return VLC_SUCCESS;
>>   }
>>   
>> -static void DecoderUpdateStatVideo( struct decoder_owner *p_owner,
>> -                                    unsigned decoded, unsigned lost )
>> +static void DecoderOutputThreads_UpdateStatVideo( struct decoder_owner
>> *p_owner,
>> +                                                  unsigned decoded,
>> unsigned lost )
>>   {
>>       unsigned displayed = 0;
>>   
>> @@ -1067,12 +1067,12 @@ static void DecoderUpdateStatVideo( struct
>> decoder_owner *p_owner,
>>       decoder_Notify(p_owner, on_new_video_stats, decoded, lost,
>> displayed);
>>   }
>>   
>> -static void DecoderQueueVideo( decoder_t *p_dec, picture_t *p_pic )
>> +static void DecoderOutputThreads_QueueVideo( decoder_t *p_dec,
>> picture_t *p_pic )
>>   {
>>       assert( p_pic );
>>       struct decoder_owner *p_owner = dec_get_owner( p_dec );
>>   
>> -    int success = DecoderPlayVideo( p_owner, p_pic );
>> +    int success = DecoderOutputThreads_PlayVideo( p_owner, p_pic );
>>   
>>       p_owner->pf_update_stat( p_owner, 1, success != VLC_SUCCESS ? 1 :
>> 0 );
>>   }
>> @@ -1105,7 +1105,7 @@ static void DecoderQueueThumbnail( decoder_t
>> *p_dec, picture_t *p_pic )
>>   
>>   }
>>   
>> -static int DecoderPlayAudio( struct decoder_owner *p_owner, block_t
>> *p_audio )
>> +static int DecoderOutputThreads_PlayAudio( struct decoder_owner
>> *p_owner, block_t *p_audio )
>>   {
>>       decoder_t *p_dec = &p_owner->dec;
>>   
>> @@ -1169,15 +1169,15 @@ static int DecoderPlayAudio( struct
>> decoder_owner *p_owner, block_t *p_audio )
>>       else if( status == AOUT_DEC_FAILED )
>>       {
>>           /* If we reload because the aout failed, we should release it.
>> That
>> -            * way, a next call to aout_update_format() won't re-use the
>> +            * way, a next call to
>> DecoderOutputThreads_UpdateAudioFormat() won't re-use the
>>               * previous (failing) aout but will try to create a new
>> one. */
>>           atomic_store( &p_owner->reload, RELOAD_DECODER_AOUT );
>>       }
>>       return VLC_SUCCESS;
>>   }
>>   
>> -static void DecoderUpdateStatAudio( struct decoder_owner *p_owner,
>> -                                    unsigned decoded, unsigned lost )
>> +static void DecoderOutputThreads_UpdateStatAudio( struct decoder_owner
>> *p_owner,
>> +                                                  unsigned decoded,
>> unsigned lost )
>>   {
>>       unsigned played = 0;
>>   
>> @@ -1192,16 +1192,16 @@ static void DecoderUpdateStatAudio( struct
>> decoder_owner *p_owner,
>>       decoder_Notify(p_owner, on_new_audio_stats, decoded, lost, played);
>>   }
>>   
>> -static void DecoderQueueAudio( decoder_t *p_dec, block_t *p_aout_buf )
>> +static void DecoderOutputThreads_QueueAudio( decoder_t *p_dec, block_t
>> *p_aout_buf )
>>   {
>>       struct decoder_owner *p_owner = dec_get_owner( p_dec );
>>   
>> -    int success = DecoderPlayAudio( p_owner, p_aout_buf );
>> +    int success = DecoderOutputThreads_PlayAudio( p_owner, p_aout_buf );
>>   
>>       p_owner->pf_update_stat( p_owner, 1, success != VLC_SUCCESS ? 1 : 0 );
>>   }
>>   
>> -static void DecoderPlaySpu( struct decoder_owner *p_owner,
>> subpicture_t *p_subpic )
>> +static void DecoderOutputThreads_PlaySpu( 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;
>> @@ -1235,13 +1235,13 @@ static void DecoderPlaySpu( struct
>> decoder_owner *p_owner, subpicture_t *p_subpi
>>       vout_PutSubpicture( p_vout, p_subpic );
>>   }
>>   
>> -static void DecoderUpdateStatSpu( struct decoder_owner *p_owner,
>> +static void DecoderOutputThreads_UpdateStatSpu( struct decoder_owner *p_owner,
>>                                     unsigned decoded, unsigned lost )
>>   {
>>       (void) p_owner; (void) decoded; (void) lost;
>>   }
>>   
>> -static void DecoderQueueSpu( decoder_t *p_dec, subpicture_t *p_spu )
>> +static void DecoderOutputThreads_QueueSpu( decoder_t *p_dec,
>> subpicture_t *p_spu )
>>   {
>>       assert( p_spu );
>>       struct decoder_owner *p_owner = dec_get_owner( p_dec );
>> @@ -1261,12 +1261,12 @@ static void DecoderQueueSpu( decoder_t *p_dec,
>> subpicture_t *p_spu )
>>       else
>>       {
>>           vlc_mutex_unlock( &p_owner->lock );
>> -        DecoderPlaySpu( p_owner, p_spu );
>> +        DecoderOutputThreads_PlaySpu( 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 DecoderThread_ProcessInput( struct decoder_owner *p_owner,
>> block_t *p_block );
>> +static void DecoderThread_DecodeBlock( struct decoder_owner *p_owner,
>> block_t *p_block )
>>   {
>>       decoder_t *p_dec = &p_owner->dec;
>>   
>> @@ -1286,7 +1286,7 @@ static void DecoderDecode( struct decoder_owner
>> *p_owner, block_t *p_block )
>>               if( !( p_block->i_flags & BLOCK_FLAG_CORE_PRIVATE_RELOADED
>> ) )
>>               {
>>                   p_block->i_flags |= BLOCK_FLAG_CORE_PRIVATE_RELOADED;
>> -                DecoderProcess( p_owner, p_block );
>> +                DecoderThread_ProcessInput( p_owner, p_block );
>>               }
>>               else /* We prefer loosing this block than an infinite
>> recursion */
>>                   block_Release( p_block );
>> @@ -1302,7 +1302,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 DecoderThread_ProcessInput( struct decoder_owner *p_owner,
>> block_t *p_block )
>>   {
>>       decoder_t *p_dec = &p_owner->dec;
>>   
>> @@ -1310,7 +1310,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
>> +     * DecoderThread_ProcessInput() 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;
>> @@ -1319,7 +1319,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( DecoderThread_Reload( p_owner, false, &p_dec->fmt_in,
>> reload ) != VLC_SUCCESS )
>>               goto error;
>>       }
>>   
>> @@ -1360,10 +1360,10 @@ 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 );
>> +                DecoderThread_DecodeBlock( p_owner, NULL );
>>   
>> -                if( ReloadDecoder( p_owner, false,
>> &p_packetizer->fmt_out,
>> -                                   RELOAD_DECODER ) != VLC_SUCCESS )
>> +                if( DecoderThread_Reload( p_owner, false,
>> &p_packetizer->fmt_out,
>> +                                          RELOAD_DECODER ) !=
>> VLC_SUCCESS )
>>                   {
>>                       block_ChainRelease( p_packetized_block );
>>                       return;
>> @@ -1378,7 +1378,7 @@ static void DecoderProcess( struct decoder_owner
>> *p_owner, block_t *p_block )
>>                   block_t *p_next = p_packetized_block->p_next;
>>                   p_packetized_block->p_next = NULL;
>>   
>> -                DecoderDecode( p_owner, p_packetized_block );
>> +                DecoderThread_DecodeBlock( p_owner, p_packetized_block
>> );
>>                   if( p_owner->error )
>>                   {
>>                       block_ChainRelease( p_next );
>> @@ -1390,10 +1390,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 );
>> +            DecoderThread_DecodeBlock( p_owner, NULL );
>>       }
>>       else
>> -        DecoderDecode( p_owner, p_block );
>> +        DecoderThread_DecodeBlock( p_owner, p_block );
>>       return;
>>   
>>   error:
>> @@ -1401,7 +1401,7 @@ error:
>>           block_Release( p_block );
>>   }
>>   
>> -static void DecoderProcessFlush( struct decoder_owner *p_owner )
>> +static void DecoderThread_Flush( struct decoder_owner *p_owner )
>>   {
>>       decoder_t *p_dec = &p_owner->dec;
>>       decoder_t *p_packetizer = p_owner->p_packetizer;
>> @@ -1456,7 +1456,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 DecoderThread_ChangePause( struct decoder_owner *p_owner,
>> bool paused, vlc_tick_t date )
>>   {
>>       decoder_t *p_dec = &p_owner->dec;
>>   
>> @@ -1482,7 +1482,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 DecoderThread_ChangeRate( struct decoder_owner *p_owner,
>> float rate )
>>   {
>>       decoder_t *p_dec = &p_owner->dec;
>>   
>> @@ -1513,7 +1513,7 @@ static void OutputChangeRate( struct
>> decoder_owner *p_owner, float rate )
>>       vlc_mutex_unlock( &p_owner->lock );
>>   }
>>   
>> -static void OutputChangeDelay( struct decoder_owner *p_owner,
>> vlc_tick_t delay )
>> +static void DecoderThread_ChangeDelay( struct decoder_owner *p_owner,
>> vlc_tick_t delay )
>>   {
>>       decoder_t *p_dec = &p_owner->dec;
>>   
>> @@ -1574,12 +1574,12 @@ static void *DecoderThread( void *p_data )
>>               vlc_fifo_Unlock( p_owner->p_fifo );
>>   
>>               /* Flush the decoder (and the output) */
>> -            DecoderProcessFlush( p_owner );
>> +            DecoderThread_Flush( p_owner );
>>   
>>               vlc_fifo_Lock( p_owner->p_fifo );
>>               vlc_restorecancel( canc );
>>   
>> -            /* Reset flushing after DecoderProcess in case
>> input_DecoderFlush
>> +            /* Reset flushing after DecoderThread_ProcessInput in case
>> input_DecoderFlush
>>                * is called again. This will avoid a second useless flush
>> (but
>>                * harmless). */
>>               p_owner->flushing = false;
>> @@ -1588,7 +1588,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
>> DecoderThread_ChangePause/DecoderThread_ChangeRate code path
>>            * if needed. */
>>           if( p_owner->reset_out_state )
>>           {
>> @@ -1606,7 +1606,7 @@ static void *DecoderThread( void *p_data )
>>               paused = p_owner->paused;
>>               vlc_fifo_Unlock( p_owner->p_fifo );
>>   
>> -            OutputChangePause( p_owner, paused, date );
>> +            DecoderThread_ChangePause( p_owner, paused, date );
>>   
>>               vlc_restorecancel( canc );
>>               vlc_fifo_Lock( p_owner->p_fifo );
>> @@ -1620,7 +1620,7 @@ static void *DecoderThread( void *p_data )
>>               rate = p_owner->request_rate;
>>               vlc_fifo_Unlock( p_owner->p_fifo );
>>   
>> -            OutputChangeRate( p_owner, rate );
>> +            DecoderThread_ChangeRate( p_owner, rate );
>>   
>>               vlc_restorecancel( canc );
>>               vlc_fifo_Lock( p_owner->p_fifo );
>> @@ -1633,7 +1633,7 @@ static void *DecoderThread( void *p_data )
>>               delay = p_owner->delay;
>>               vlc_fifo_Unlock( p_owner->p_fifo );
>>   
>> -            OutputChangeDelay( p_owner, delay );
>> +            DecoderThread_ChangeDelay( p_owner, delay );
>>   
>>               vlc_restorecancel( canc );
>>               vlc_fifo_Lock( p_owner->p_fifo );
>> @@ -1669,7 +1669,7 @@ static void *DecoderThread( void *p_data )
>>           vlc_fifo_Unlock( p_owner->p_fifo );
>>   
>>           int canc = vlc_savecancel();
>> -        DecoderProcess( p_owner, p_block );
>> +        DecoderThread_ProcessInput( 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
>> @@ -1697,10 +1697,10 @@ static void *DecoderThread( void *p_data )
>>   static const struct decoder_owner_callbacks dec_video_cbs =
>>   {
>>       .video = {
>> -        .format_update = vout_update_format,
>> -        .buffer_new = vout_new_buffer,
>> -        .queue = DecoderQueueVideo,
>> -        .queue_cc = DecoderQueueCc,
>> +        .format_update = DecoderOutputThreads_UpdateVideoFormat,
>> +        .buffer_new = DecoderOutputThreads_NewVideoBuffer,
>> +        .queue = DecoderOutputThreads_QueueVideo,
>> +        .queue_cc = DecoderOutputThreads_QueueCc,
>>           .get_display_date = DecoderGetDisplayDate,
>>           .get_display_rate = DecoderGetDisplayRate,
>>       },
>> @@ -1718,16 +1718,16 @@ static const struct decoder_owner_callbacks
>> dec_thumbnailer_cbs =
>>   static const struct decoder_owner_callbacks dec_audio_cbs =
>>   {
>>       .audio = {
>> -        .format_update = aout_update_format,
>> -        .queue = DecoderQueueAudio,
>> +        .format_update = DecoderOutputThreads_UpdateAudioFormat,
>> +        .queue = DecoderOutputThreads_QueueAudio,
>>       },
>>       .get_attachments = DecoderGetInputAttachments,
>>   };
>>   static const struct decoder_owner_callbacks dec_spu_cbs =
>>   {
>>       .spu = {
>> -        .buffer_new = spu_new_buffer,
>> -        .queue = DecoderQueueSpu,
>> +        .buffer_new = DecoderOutputThreads_NewSpuBuffer,
>> +        .queue = DecoderOutputThreads_QueueSpu,
>>       },
>>       .get_attachments = DecoderGetInputAttachments,
>>   };
>> @@ -1836,15 +1836,15 @@ static struct decoder_owner * CreateDecoder(
>> vlc_object_t *p_parent,
>>                   p_dec->cbs = &dec_video_cbs;
>>               else
>>                   p_dec->cbs = &dec_thumbnailer_cbs;
>> -            p_owner->pf_update_stat = DecoderUpdateStatVideo;
>> +            p_owner->pf_update_stat =
>> DecoderOutputThreads_UpdateStatVideo;
>>               break;
>>           case AUDIO_ES:
>>               p_dec->cbs = &dec_audio_cbs;
>> -            p_owner->pf_update_stat = DecoderUpdateStatAudio;
>> +            p_owner->pf_update_stat =
>> DecoderOutputThreads_UpdateStatAudio;
>>               break;
>>           case SPU_ES:
>>               p_dec->cbs = &dec_spu_cbs;
>> -            p_owner->pf_update_stat = DecoderUpdateStatSpu;
>> +            p_owner->pf_update_stat =
>> DecoderOutputThreads_UpdateStatSpu;
>>               break;
>>           default:
>>               msg_Err( p_dec, "unknown ES format" );
>> -- 
>> 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