<html><head></head><body><div class="gmail_quote">Le 1 juillet 2017 16:54:42 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">---<br /> src/input/decoder.c | 20 ++++++++++++++++++++<br /> 1 file changed, 20 insertions(+)<br /><br />diff --git a/src/input/decoder.c b/src/input/decoder.c<br />index dac313737a..23e5a7356b 100644<br />--- a/src/input/decoder.c<br />+++ b/src/input/decoder.c<br />@@ -54,6 +54,11 @@<br /> <br /> #include "../video_output/vout_control.h"<br /> <br />+/* Number of vout request failures after we slow down vout requests */<br />+#define VOUT_MAX_FAILURE 10<br />+/* Delay between each failing vout requests */<br />+#define VOUT_RETRY_DELAY 1000000UL<br />+<br /> /*<br />  * Possibles values set in p_owner->reload atomic<br />  */<br />@@ -108,6 +113,8 @@ struct decoder_owner_sys_t<br />     audio_output_t *p_aout;<br /> <br />     vout_thread_t   *p_vout;<br />+    unsigned         vout_nb_failures;<br />+    mtime_t          vout_last_failure;<br /> <br />     /* -- Theses variables need locking on read *and* write -- */<br />     /* Preroll */<br />@@ -408,6 +415,13 @@ static int vout_update_format( decoder_t *p_dec )<br /> {<br />     decoder_owner_sys_t *p_owner = p_dec->p_owner;<br /> <br />+    /* Avoid to spam vout requests if no vout is capable of handling the<br />+     * current format. We should still request vouts from time to time since a<br />+     * vout can become available in between. */<br />+    if( p_owner->vout_nb_failures > VOUT_MAX_FAILURE<br />+     && mdate() - p_owner->vout_last_failure < VOUT_RETRY_DELAY )<br />+        return -1;<br />+<br />     if( p_owner->p_vout == NULL<br />      || p_dec->fmt_<a href="http://out.video">out.video</a>.i_width != p_owner-><a href="http://fmt.video">fmt.video</a>.i_width<br />      || p_dec->fmt_<a href="http://out.video">out.video</a>.i_height != p_owner-><a href="http://fmt.video">fmt.video</a>.i_height<br />@@ -530,8 +544,12 @@ static int vout_update_format( decoder_t *p_dec )<br />         if( p_vout == NULL )<br />         {<br />             msg_Err( p_dec, "failed to create video output" );<br />+            p_owner->vout_nb_failures++;<br />+            p_owner->vout_last_failure = mdate();<br />             return -1;<br />         }<br />+        p_owner->vout_nb_failures = 0;<br />+        p_owner->vout_last_failure = 0;<br />     }<br /> <br />     if ( memcmp( &p_dec->fmt_<a href="http://out.video">out.video</a>.mastering,<br />@@ -1662,6 +1680,8 @@ static decoder_t * CreateDecoder( vlc_object_t *p_parent,<br />     p_owner->p_resource = p_resource;<br />     p_owner->p_aout = NULL;<br />     p_owner->p_vout = NULL;<br />+    p_owner->vout_nb_failures = 0;<br />+    p_owner->vout_last_failure = 0;<br />     p_owner->p_spu_vout = NULL;<br />     p_owner->i_spu_channel = 0;<br />     p_owner->i_spu_order = 0;</pre></blockquote></div><br clear="all">AFAICT, retrying does not make sense. Just fail immediately if the format is the same as before. It cannot be assumed that the decoder will actually keep retrying with the same format (even now, that is not always true).<br>
<br>
With that said, you can't expect this to really prevent spam. The decoder could just as well iterate multiple failing formats again and again. So I'd say this patch is kinda useless.<br>
-- <br>
Rémi Denis-Courmont<br>
Typed on an inconvenient virtual keyboard</body></html>