<html><head></head><body>There should not be a need to move the current state out of the stack, AFAIU.<br>
<br>
I like to keep thread variables on stack because it's then obvious what the access rule is (read/write for the thread) and if the variable becomes unused.<br><br><div class="gmail_quote">Le 3 juillet 2018 12:15:52 GMT+03: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">The aout/vout paused/rate state was not set if the output was restarted within<br>the lifetime of the decoder.<br>---<br> src/input/decoder.c | 66 +++++++++++++++++++++++++++------------------<br> 1 file changed, 40 insertions(+), 26 deletions(-)<br><br>diff --git a/src/input/decoder.c b/src/input/decoder.c<br>index 27dbfba50d..3e5d14814c 100644<br>--- a/src/input/decoder.c<br>+++ b/src/input/decoder.c<br>@@ -112,10 +112,12 @@ struct decoder_owner<br> /* Preroll */<br> vlc_tick_t i_preroll_end;<br> /* Pause & Rate */<br>- vlc_tick_t pause_date;<br>- float rate;<br>+ vlc_tick_t request_pause_date;<br>+ float request_rate;<br>+ float output_rate;<br> unsigned frames_countdown;<br>- bool paused;<br>+ bool request_paused;<br>+ bool output_paused;<br> <br> bool error;<br> <br>@@ -284,6 +286,17 @@ static void DecoderUpdateFormatLocked( decoder_t *p_dec )<br> /*****************************************************************************<br> * Buffers allocation callbacks for the decoders<br> *****************************************************************************/<br>+static void out_reset_state( decoder_t *p_dec )<br>+{<br>+ struct decoder_owner *p_owner = dec_get_owner( p_dec );<br>+<br>+ vlc_fifo_Lock( p_owner->p_fifo );<br>+ p_owner->output_rate = 1.f;<br>+ p_owner->output_paused = false;<br>+ vlc_fifo_Unlock( p_owner->p_fifo );<br>+<br>+}<br>+<br> static vout_thread_t *aout_request_vout( void *p_private,<br> vout_thread_t *p_vout,<br> const video_format_t *p_fmt, bool b_recyle )<br>@@ -406,6 +419,8 @@ static int aout_update_format( decoder_t *p_dec )<br> p_owner->fmt.audio.i_bytes_per_frame;<br> p_dec->fmt_out.audio.i_frame_length =<br> p_owner->fmt.audio.i_frame_length;<br>+<br>+ out_reset_state( p_dec );<br> }<br> return 0;<br> }<br>@@ -538,6 +553,7 @@ static int vout_update_format( decoder_t *p_dec )<br> msg_Err( p_dec, "failed to create video output" );<br> return -1;<br> }<br>+ out_reset_state( p_dec );<br> }<br> <br> if ( memcmp( &p_dec->fmt_out.video.mastering,<br>@@ -628,7 +644,7 @@ static vlc_tick_t DecoderGetDisplayDate( decoder_t *p_dec, vlc_tick_t i_ts )<br> struct decoder_owner *p_owner = dec_get_owner( p_dec );<br> <br> vlc_mutex_lock( &p_owner->lock );<br>- if( p_owner->b_waiting || p_owner->paused )<br>+ if( p_owner->b_waiting || p_owner->request_paused )<br> i_ts = VLC_TICK_INVALID;<br> vlc_mutex_unlock( &p_owner->lock );<br> <br>@@ -1016,7 +1032,7 @@ static void DecoderPlayVideo( decoder_t *p_dec, picture_t *p_picture,<br> /* FIXME: The *input* FIFO should not be locked here. This will not work<br> * properly if/when pictures are queued asynchronously. */<br> vlc_fifo_Lock( p_owner->p_fifo );<br>- if( unlikely(p_owner->paused) && likely(p_owner->frames_countdown > 0) )<br>+ if( unlikely(p_owner->request_paused) && likely(p_owner->frames_countdown > 0) )<br> p_owner->frames_countdown--;<br> vlc_fifo_Unlock( p_owner->p_fifo );<br> <br>@@ -1561,8 +1577,6 @@ static void *DecoderThread( void *p_data )<br> {<br> decoder_t *p_dec = (decoder_t *)p_data;<br> struct decoder_owner *p_owner = dec_get_owner( p_dec );<br>- float rate = 1.f;<br>- bool paused = false;<br> <br> /* The decoder's main loop */<br> vlc_fifo_Lock( p_owner->p_fifo );<br>@@ -1591,11 +1605,11 @@ static void *DecoderThread( void *p_data )<br> continue;<br> }<br> <br>- if( paused != p_owner->paused )<br>+ if( p_owner->output_paused != p_owner->request_paused )<br> { /* Update playing/paused status of the output */<br> int canc = vlc_savecancel();<br>- bool request_paused = p_owner->paused;<br>- vlc_tick_t request_date = p_owner->pause_date;<br>+ bool request_paused = p_owner->request_paused;<br>+ vlc_tick_t request_date = p_owner->request_pause_date;<br> <br> vlc_fifo_Unlock( p_owner->p_fifo );<br> <br>@@ -1605,14 +1619,14 @@ static void *DecoderThread( void *p_data )<br> vlc_restorecancel( canc );<br> vlc_fifo_Lock( p_owner->p_fifo );<br> if (success)<br>- paused = request_paused;<br>+ p_owner->output_paused = request_paused;<br> continue;<br> }<br> <br>- if( rate != p_owner->rate )<br>+ if( p_owner->output_rate != p_owner->request_rate )<br> {<br> int canc = vlc_savecancel();<br>- float request_rate = p_owner->rate;<br>+ float request_rate = p_owner->request_rate;<br> <br> vlc_fifo_Unlock( p_owner->p_fifo );<br> <br>@@ -1622,10 +1636,10 @@ static void *DecoderThread( void *p_data )<br> vlc_restorecancel( canc );<br> vlc_fifo_Lock( p_owner->p_fifo );<br> if (success)<br>- rate = request_rate;<br>+ p_owner->output_rate = request_rate;<br> }<br> <br>- if( p_owner->paused && p_owner->frames_countdown == 0 )<br>+ if( p_owner->request_paused && p_owner->frames_countdown == 0 )<br> { /* Wait for resumption from pause */<br> p_owner->b_idle = true;<br> vlc_cond_signal( &p_owner->wait_acknowledge );<br>@@ -1746,9 +1760,9 @@ static decoder_t * CreateDecoder( vlc_object_t *p_parent,<br> p_owner->b_fmt_description = false;<br> p_owner->p_description = NULL;<br> <br>- p_owner->rate = 1.f;<br>- p_owner->paused = false;<br>- p_owner->pause_date = VLC_TICK_INVALID;<br>+ p_owner->request_rate = p_owner->output_rate = 1.f;<br>+ p_owner->request_paused = p_owner->output_paused = false;<br>+ p_owner->request_pause_date = VLC_TICK_INVALID;<br> p_owner->frames_countdown = 0;<br> <br> p_owner->b_waiting = false;<br>@@ -2209,7 +2223,7 @@ void input_DecoderFlush( decoder_t *p_dec )<br> <br> /* Flush video/spu decoder when paused: increment frames_countdown in order<br> * to display one frame/subtitle */<br>- if( p_owner->paused<br>+ if( p_owner->request_paused<br> && ( p_owner->fmt.i_cat == VIDEO_ES || p_owner->fmt.i_cat == SPU_ES )<br> && p_owner->frames_countdown == 0 )<br> p_owner->frames_countdown++;<br>@@ -2330,8 +2344,8 @@ void input_DecoderChangePause( decoder_t *p_dec, bool b_paused, vlc_tick_t i_dat<br> * while the input is paused (e.g. add sub file), then b_paused is<br> * (incorrectly) false. FIXME: This is a bug in the decoder owner. */<br> vlc_fifo_Lock( p_owner->p_fifo );<br>- p_owner->paused = b_paused;<br>- p_owner->pause_date = i_date;<br>+ p_owner->request_paused = b_paused;<br>+ p_owner->request_pause_date = i_date;<br> p_owner->frames_countdown = 0;<br> vlc_fifo_Signal( p_owner->p_fifo );<br> vlc_fifo_Unlock( p_owner->p_fifo );<br>@@ -2342,7 +2356,7 @@ void input_DecoderChangeRate( decoder_t *dec, float rate )<br> struct decoder_owner *owner = dec_get_owner( dec );<br> <br> vlc_fifo_Lock( owner->p_fifo );<br>- owner->rate = rate;<br>+ owner->request_rate = rate;<br> vlc_fifo_Signal( owner->p_fifo );<br> vlc_fifo_Unlock( owner->p_fifo );<br> }<br>@@ -2391,9 +2405,9 @@ void input_DecoderWait( decoder_t *p_dec )<br> vlc_mutex_lock( &p_owner->lock );<br> while( !p_owner->b_has_data )<br> {<br>- /* Don't need to lock p_owner->paused since it's only modified by the<br>- * owner */<br>- if( p_owner->paused )<br>+ /* Don't need to lock p_owner->request_paused since it's only modified<br>+ * by the owner */<br>+ if( p_owner->request_paused )<br> break;<br> vlc_fifo_Lock( p_owner->p_fifo );<br> if( p_owner->b_idle && vlc_fifo_IsEmpty( p_owner->p_fifo ) )<br>@@ -2412,7 +2426,7 @@ void input_DecoderFrameNext( decoder_t *p_dec, vlc_tick_t *pi_duration )<br> {<br> struct decoder_owner *p_owner = dec_get_owner( p_dec );<br> <br>- assert( p_owner->paused );<br>+ assert( p_owner->request_paused );<br> *pi_duration = 0;<br> <br> vlc_fifo_Lock( p_owner->p_fifo );</pre></blockquote></div><br>
-- <br>
Envoyé de mon appareil Android avec Courriel K-9 Mail. Veuillez excuser ma brièveté.</body></html>