<html><head></head><body>Hi,<br><br>I violently agree that there should be a clear separation between the generic ("owner") functions, and the ES output functions.<br><br>However, I think it makes more sense to keep the (vlc_)dec(oder)_ prefix for the generic case, and (vlc_)input_dec(oder)_ prefix for the ES output.<br><br><div class="gmail_quote">Le 19 février 2019 14:41:48 GMT+02:00, Thomas Guillem <thomas@gllm.fr> a écrit :<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<pre class="k9mail">Why not calling it decoder_Unload() since its mean goal is to unload the decoder module.<br><br>You should really use an other prefix for decoder owner functions. I really don't like having the the same prefix for functions that can only be used by the owner and some by module implementations.<br><br>vlc_dec_owner, for example. <br><br>On Mon, Feb 18, 2019, at 16:11, Steve Lhomme wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 1ex 0.8ex; border-left: 1px solid #729fcf; padding-left: 1ex;">vlc | branch: master | Steve Lhomme <robux4@ycbcr.xyz> | Mon Feb 18 <br>15:02:10 2019 +0100| [55ae595eb5e80b4fc66de90803e802e2aa70a77f] | <br>committer: Steve Lhomme<br><br>decoder: make decoder_Clean() public<br><br>The decoder and decoder tests actually load/unload decoders without resetting<br>the whole structure.<br><br><blockquote class="gmail_quote" style="margin: 0pt 0pt 1ex 0.8ex; border-left: 1px solid #ad7fa8; padding-left: 1ex;"><a href="http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=55ae595eb5e80b4fc66de90803e802e2aa70a77f">http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=55ae595eb5e80b4fc66de90803e802e2aa70a77f</a><br></blockquote><hr>  include/vlc_codec.h         |  7 +++++++<br>  src/input/decoder.c         | 32 +++++---------------------------<br>  src/input/decoder_helpers.c |  2 +-<br>  src/libvlccore.sym          |  1 +<br>  test/src/input/decoder.c    | 20 ++------------------<br>  5 files changed, 16 insertions(+), 46 deletions(-)<br> <br> diff --git a/include/vlc_codec.h b/include/vlc_codec.h<br> index 2042ad2424..3961b8c9a1 100644<br> --- a/include/vlc_codec.h<br> +++ b/include/vlc_codec.h<br> @@ -327,6 +327,13 @@ VLC_API void decoder_Init( decoder_t *dec, const <br> es_format_t * );<br>  VLC_API void decoder_Destroy( decoder_t **p_dec );<br>  <br>  /**<br> + * Unload a decoder module and reset the input/output formats.<br> + *<br> + * To be used by decoder owners.<br> + */<br> +VLC_API void decoder_Clean( decoder_t *p_dec );<br> +<br> +/**<br>   * This function queues a single picture to the video output.<br>   *<br>   * \note<br> diff --git a/src/input/decoder.c b/src/input/decoder.c<br> index 05ba7f6abb..582a2eaf2e 100644<br> --- a/src/input/decoder.c<br> +++ b/src/input/decoder.c<br> @@ -189,38 +189,16 @@ static int LoadDecoder( decoder_t *p_dec, bool <br> b_packetizer,<br>  <br>      if( !p_dec->p_module )<br>      {<br> -        es_format_Clean( &p_dec->fmt_in );<br> +        decoder_Clean( p_dec );<br>          return -1;<br>      }<br> -    else<br> -        return 0;<br> -}<br> -<br> -/**<br> - * Unload a decoder module<br> - */<br> -static void UnloadDecoder( decoder_t *p_dec )<br> -{<br> -    if( p_dec->p_module )<br> -    {<br> -        module_unneed( p_dec, p_dec->p_module );<br> -        p_dec->p_module = NULL;<br> -    }<br> -<br> -    if( p_dec->p_description )<br> -    {<br> -        vlc_meta_Delete( p_dec->p_description );<br> -        p_dec->p_description = NULL;<br> -    }<br> -<br> -    es_format_Clean( &p_dec->fmt_in );<br> -    es_format_Clean( &p_dec->fmt_out );<br> +    return 0;<br>  }<br>  <br>  static int ReloadDecoder( decoder_t *p_dec, bool b_packetizer,<br>                            const es_format_t *restrict p_fmt, enum <br> reload reload )<br>  {<br> -    /* Copy p_fmt since it can be destroyed by UnloadDecoder */<br> +    /* Copy p_fmt since it can be destroyed by decoder_Clean */<br>      struct decoder_owner *p_owner = dec_get_owner( p_dec );<br>      es_format_t fmt_in;<br>      if( es_format_Copy( &fmt_in, p_fmt ) != VLC_SUCCESS )<br> @@ -230,7 +208,7 @@ static int ReloadDecoder( decoder_t *p_dec, bool <br> b_packetizer,<br>      }<br>  <br>      /* Restart the decoder module */<br> -    UnloadDecoder( p_dec );<br> +    decoder_Clean( p_dec );<br>      p_owner->error = false;<br>  <br>      if( reload == RELOAD_DECODER_AOUT )<br> @@ -1974,7 +1952,7 @@ static void DeleteDecoder( decoder_t * p_dec )<br>               (char*)&p_dec->fmt_in.i_codec );<br>  <br>      const enum es_format_category_e i_cat =p_dec->fmt_in.i_cat;<br> -    UnloadDecoder( p_dec );<br> +    decoder_Clean( p_dec );<br>  <br>      /* Free all packets still in the decoder fifo. */<br>      block_FifoRelease( p_owner->p_fifo );<br> diff --git a/src/input/decoder_helpers.c b/src/input/decoder_helpers.c<br> index b60b830123..693c6b3955 100644<br> --- a/src/input/decoder_helpers.c<br> +++ b/src/input/decoder_helpers.c<br> @@ -46,7 +46,7 @@ void decoder_Init( decoder_t *p_dec, const <br> es_format_t *restrict p_fmt )<br>      es_format_Init( &p_dec->fmt_out, p_fmt->i_cat, 0 );<br>  }<br>  <br> -static void decoder_Clean( decoder_t *p_dec )<br> +void decoder_Clean( decoder_t *p_dec )<br>  {<br>      es_format_Clean( &p_dec->fmt_in );<br>      es_format_Clean( &p_dec->fmt_out );<br> diff --git a/src/libvlccore.sym b/src/libvlccore.sym<br> index 906a449f2b..d2d1dac6fb 100644<br> --- a/src/libvlccore.sym<br> +++ b/src/libvlccore.sym<br> @@ -74,6 +74,7 @@ date_Decrement<br>  date_Increment<br>  date_Init<br>  decoder_Init<br> +decoder_Clean<br>  decoder_Destroy<br>  decoder_AbortPictures<br>  decoder_NewAudioBuffer<br> diff --git a/test/src/input/decoder.c b/test/src/input/decoder.c<br> index 6ecc584120..df05fcf4ce 100644<br> --- a/test/src/input/decoder.c<br> +++ b/test/src/input/decoder.c<br> @@ -106,28 +106,12 @@ static int decoder_load(decoder_t *decoder, bool <br> is_packetizer,<br>  <br>      if (!decoder->p_module)<br>      {<br> -        es_format_Clean(&decoder->fmt_in);<br> +        decoder_Clean( decoder );<br>          return VLC_EGENERIC;<br>      }<br>      return VLC_SUCCESS;<br>  }<br>  <br> -static void decoder_unload(decoder_t *decoder)<br> -{<br> -    if (decoder->p_module != NULL)<br> -    {<br> -        module_unneed(decoder, decoder->p_module);<br> -        decoder->p_module = NULL;<br> -        es_format_Clean(&decoder->fmt_out);<br> -    }<br> -    es_format_Clean(&decoder->fmt_in);<br> -    if (decoder->p_description)<br> -    {<br> -        vlc_meta_Delete(decoder->p_description);<br> -        decoder->p_description = NULL;<br> -    }<br> -}<br> -<br>  void test_decoder_destroy(decoder_t *decoder)<br>  {<br>      struct decoder_owner *owner = dec_get_owner(decoder);<br> @@ -237,7 +221,7 @@ int test_decoder_process(decoder_t *decoder, <br> block_t *p_block)<br>              decoder->pf_decode(decoder, NULL);<br>  <br>              /* Reload decoder */<br> -            decoder_unload(decoder);<br> +            decoder_Clean(decoder);<br>              if (decoder_load(decoder, false, &packetizer->fmt_out) != <br> VLC_SUCCESS)<br>              {<br>                  block_ChainRelease(p_packetized_block);<hr> vlc-commits mailing list<br> vlc-commits@videolan.org<br> <a href="https://mailman.videolan.org/listinfo/vlc-commits">https://mailman.videolan.org/listinfo/vlc-commits</a><br><br></blockquote><hr>vlc-devel mailing list<br>To unsubscribe or modify your subscription options:<br><a href="https://mailman.videolan.org/listinfo/vlc-devel">https://mailman.videolan.org/listinfo/vlc-devel</a></pre></blockquote></div><br>-- <br>Envoyé de mon appareil Android avec Courriel K-9 Mail. Veuillez excuser ma brièveté.</body></html>