<html><head></head><body>And by the way, I have been on the receiving end of much the same complaint about much the same thing. We agreed to use hold for reference count increases and get for getters then.<br><br><div class="gmail_quote">Le 24 septembre 2019 11:49:02 GMT+03:00, "Rémi Denis-Courmont" <remi@remlab.net> a écrit :<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
This is not specifically about callbacks. Our function names follow that convention. If you don't believe me, you can RTFS. It's not a subjective fact to disagree on.<br><br><div class="gmail_quote">Le 24 septembre 2019 10:52:07 GMT+03:00, Steve Lhomme <robux4@ycbcr.xyz> 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">On 2019-09-23 19:13, Rémi Denis-Courmont wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 1ex 0.8ex; border-left: 1px solid #729fcf; padding-left: 1ex;">Le maanantaina 23. syyskuuta 2019, 18.01.14 EEST Steve Lhomme a écrit :<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 1ex 0.8ex; border-left: 1px solid #ad7fa8; padding-left: 1ex;"> The first part is to create the decoder device.<br> The second part is to create the display module (or other depending on the<br> decoder owner).<br><br> Turn decoder_UpdateVideoFormat() is calling the two new functions.<hr>   include/vlc_codec.h         | 38 +++++++++++++++++++++++++++++++++++++<br>   src/input/decoder_helpers.c | 20 +++++++++++++++++++<br>   src/libvlccore.sym          |  2 ++<br>   3 files changed, 60 insertions(+)<br><br> diff --git a/include/vlc_codec.h b/include/vlc_codec.h<br> index 28a65846d9e..8d2680f1965 100644<br> --- a/include/vlc_codec.h<br> +++ b/include/vlc_codec.h<br> @@ -49,6 +49,7 @@ struct decoder_owner_callbacks<br>       {<br>           struct<br>           {<br> +            int         (*hold_device)( decoder_t *, vlc_decoder_device **<br> );<br></blockquote>Uh, that's very unconventional naming. Hold normally increase the reference<br>count on an object that you already have. Get returns a reference to an object<br>that you do not have. Ditto earlier.<br></blockquote><br>I disagree. get_XXX usually only gets the value (often a structure). <br>There is no hold_XXX callback in the code right now.<br><br>IMO it's important here to tell that a reference is added to the <br>returned object. Maybe hold_ alone would sound like it would hold the <br>device if one is passed. How about `get_and_hold_device` ?<br><br><blockquote class="gmail_quote" style="margin: 0pt 0pt 1ex 0.8ex; border-left: 1px solid #729fcf; padding-left: 1ex;"><blockquote class="gmail_quote" style="margin: 0pt 0pt 1ex 0.8ex; border-left: 1px solid #ad7fa8; padding-left: 1ex;"> int         (*format_update)( decoder_t * );<br>               /* cf. decoder_NewPicture, can be called from any decoder<br> thread */ @@ -253,6 +254,43 @@ struct encoder_t<br>    * @{<br>    */<br><br> +/**<br> + * Creates/Updates the output decoder device.<br> + *<br> + * This function notifies the video output pipeline of a new video output<br> + * format (fmt_out.video). If there was no decoder device so far or a new<br> + * decoder device is required, a new decoder device will be set up.<br> + * decoder_UpdateVideoOutput() can then be used.<br> + *<br> + * If the format is unchanged, this function has no effects and returns<br> zero. + *<br> + * \param dec the decoder object<br> + * \param pp_dec_dev the received of the held decoder device, NULL not to<br> get one + *<br> + * \note<br> + * This function is not reentrant.<br> + *<br> + * @return 0 if the video output was set up successfully, -1 otherwise.<br> + */<br> +VLC_API int decoder_HoldDecoderDevice( decoder_t *dec, vlc_decoder_device<br> **pp_dec_dev ); +<br> +/**<br> + * Creates/Updates the rest of the video output pipeline.<br> + *<br> + * After a call to decoder_HoldDecoderDevice() this function notifies the<br> + * video output pipeline of a new video output format (fmt_out.video). If<br> there + * was no video output from the decoder so far, a new decoder video<br> output will + * be set up. decoder_NewPicture() can then be used to<br> allocate picture buffers. + *<br> + * If the format is unchanged, this function has no effects and returns<br> zero. + *<br> + * \note<br> + * This function is not reentrant.<br> + *<br> + * @return 0 if the video output was set up successfully, -1 otherwise.<br> + */<br> +VLC_API int decoder_UpdateVideoOutput( decoder_t *dec );<br> +<br>   /**<br>    * Updates the video output format.<br>    *<br> diff --git a/src/input/decoder_helpers.c b/src/input/decoder_helpers.c<br> index 6d5b0050ed7..51e097961b9 100644<br> --- a/src/input/decoder_helpers.c<br> +++ b/src/input/decoder_helpers.c<br> @@ -76,6 +76,26 @@ void decoder_Destroy( decoder_t *p_dec )<br>   }<br><br>   int decoder_UpdateVideoFormat( decoder_t *dec )<br> +{<br> +    int res = decoder_HoldDecoderDevice( dec, NULL );<br> +    if (res == 0)<br> +        res = decoder_UpdateVideoOutput( dec );<br> +    return res;<br> +}<br> +<br> +int decoder_HoldDecoderDevice( decoder_t *dec, vlc_decoder_device<br> **pp_dec_dev ) +{<br> +    vlc_assert( dec->fmt_in.i_cat == VIDEO_ES && dec->cbs != NULL );<br> +    if ( unlikely(dec->fmt_in.i_cat != VIDEO_ES || dec->cbs == NULL ) )<br> +        return -1;<br> +<br> +    if ( dec->cbs->video.hold_device == NULL )<br> +        return 0; /* TODO make it mandatory for all decoder owners */<br> +<br> +    return dec->cbs->video.hold_device( dec, pp_dec_dev );<br> +}<br> +<br> +int decoder_UpdateVideoOutput( decoder_t *dec )<br>   {<br>       vlc_assert( dec->fmt_in.i_cat == VIDEO_ES && dec->cbs != NULL );<br>       if ( unlikely(dec->fmt_in.i_cat != VIDEO_ES || dec->cbs == NULL ||<br> diff --git a/src/libvlccore.sym b/src/libvlccore.sym<br> index e5241c411d0..fb2952ee5ef 100644<br> --- a/src/libvlccore.sym<br> +++ b/src/libvlccore.sym<br> @@ -82,6 +82,8 @@ decoder_Destroy<br>   decoder_AbortPictures<br>   decoder_NewAudioBuffer<br>   decoder_UpdateVideoFormat<br> +decoder_HoldDecoderDevice<br> +decoder_UpdateVideoOutput<br>   vlc_decoder_device_Hold<br>   vlc_decoder_device_Release<br>   demux_PacketizerDestroy<br></blockquote><br>-- <br>雷米‧德尼-库尔蒙<br><a href="http://www.remlab.net/">http://www.remlab.net/</a><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><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></blockquote></div><br>-- <br>Envoyé de mon appareil Android avec Courriel K-9 Mail. Veuillez excuser ma brièveté.</body></html>