<html><head></head><body>Hi,<br><br>AFAIK, it is, or at least was at some point, safe to read outside the lock because no other thread could write it.<br><br>It's silly to maximize lock scope. Lock scope should be minimised.<br><br><div class="gmail_quote">Le 3 septembre 2019 11:29:28 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">It's already done this way for p_vout. Since we're going to lock for writing,<br>we might as well read the value in that lock.<hr> src/input/decoder.c | 5 ++---<br> 1 file changed, 2 insertions(+), 3 deletions(-)<br><br>diff --git a/src/input/decoder.c b/src/input/decoder.c<br>index 63f858c397..25aa1e0727 100644<br>--- a/src/input/decoder.c<br>+++ b/src/input/decoder.c<br>@@ -220,9 +220,9 @@ static int ReloadDecoder( struct decoder_owner *p_owner, bool b_packetizer,<br> if( reload == RELOAD_DECODER_AOUT )<br> {<br> assert( p_owner->fmt.i_cat == AUDIO_ES );<br>- audio_output_t *p_aout = p_owner->p_aout;<br> <br> vlc_mutex_lock( &p_owner->lock );<br>+ audio_output_t *p_aout = p_owner->p_aout;<br> p_owner->p_aout = NULL;<br> vlc_mutex_unlock( &p_owner->lock );<br> if( p_aout )<br>@@ -301,10 +301,9 @@ static int aout_update_format( decoder_t *p_dec )<br> p_dec->fmt_out.i_codec != p_dec->fmt_out.audio.i_format ||<br> p_dec->fmt_out.i_profile != p_owner->fmt.i_profile ) )<br> {<br>- audio_output_t *p_aout = p_owner->p_aout;<br>-<br> /* Parameters changed, restart the aout */<br> vlc_mutex_lock( &p_owner->lock );<br>+ audio_output_t *p_aout = p_owner->p_aout;<br> p_owner->p_aout = NULL;<br> vlc_mutex_unlock( &p_owner->lock );<br> aout_DecDelete( p_aout );</pre></blockquote></div><br>-- <br>Envoyé de mon appareil Android avec Courriel K-9 Mail. Veuillez excuser ma brièveté.</body></html>