<!DOCTYPE html>
<html>
<head>
<title></title>
<style type="text/css">p.MsoNormal,p.MsoNoSpacing{margin:0}</style>
</head>
<body><div>So, I need to keep the lock while calling vout/aout Change Rate/Pause/Flush. Right?<br></div>
<pre><br></pre><div><br></div>
<div>On Thu, May 17, 2018, at 14:49, Rémi Denis-Courmont wrote:<br></div>
<blockquote type="cite"><div>No. Holding vout/aout gives access to variables and interface controls, nothing else.<br></div>
<div><br></div>
<div defang_data-gmailquote="yes"><div>Le 17 mai 2018 15:36:55 GMT+03:00, Thomas Guillem <thomas@gllm.fr> a écrit :<br></div>
<blockquote defang_data-gmailquote="yes" style="margin-top:0pt;margin-right:0pt;margin-bottom:0pt;margin-left:0.8ex;border-left-color:rgb(204, 204, 204);border-left-style:solid;border-left-width:1px;padding-left:1ex;"><pre><div>Since these variables can be written from any thread from format_update()<br></div>
<div>callbacks.<br></div>
<div>---<br></div>
<div> src/input/decoder.c | 59 +++++++++++++++++++++++++++++++++++++--------<br></div>
<div> 1 file changed, 49 insertions(+), 10 deletions(-)<br></div>
<div><br></div>
<div>diff --git a/src/input/decoder.c b/src/input/decoder.c<br></div>
<div>index 1fdc4fb7ed..e8e4c109ef 100644<br></div>
<div>--- a/src/input/decoder.c<br></div>
<div>+++ b/src/input/decoder.c<br></div>
<div>@@ -103,10 +103,11 @@ struct decoder_owner<br></div>
<div> vlc_cond_t wait_fifo; /* TODO: merge with wait_acknowledge */<br></div>
<div> vlc_cond_t wait_timed;<br></div>
<div> <br></div>
<div>- /* -- These variables need locking on write(only) -- */<br></div>
<div>+ /* These variables are written from the format_update() callbacks threads.<br></div>
<div>+ * They need locking when they are read from the DecoderThread (use<br></div>
<div>+ * dec_get_aout()/dec_get_vout() helpers). */<br></div>
<div> audio_output_t *p_aout;<br></div>
<div>-<br></div>
<div>- vout_thread_t *p_vout;<br></div>
<div>+ vout_thread_t *p_vout;<br></div>
<div> <br></div>
<div> /* -- Theses variables need locking on read *and* write -- */<br></div>
<div> /* Preroll */<br></div>
<div>@@ -158,6 +159,24 @@ static inline struct decoder_owner *dec_get_owner( decoder_t *p_dec )<br></div>
<div> return container_of( p_dec, struct decoder_owner, dec );<br></div>
<div> }<br></div>
<div> <br></div>
<div>+static audio_output_t *dec_get_aout( decoder_t *p_dec )<br></div>
<div>+{<br></div>
<div>+ struct decoder_owner *p_owner = dec_get_owner( p_dec );<br></div>
<div>+ vlc_mutex_lock( &p_owner->lock );<br></div>
<div>+ audio_output_t *p_aout = p_owner->p_aout ? vlc_object_hold( p_owner->p_aout ) : NULL;<br></div>
<div>+ vlc_mutex_unlock( &p_owner->lock );<br></div>
<div>+ return p_aout;<br></div>
<div>+}<br></div>
<div>+<br></div>
<div>+static vout_thread_t *dec_get_vout( decoder_t *p_dec )<br></div>
<div>+{<br></div>
<div>+ struct decoder_owner *p_owner = dec_get_owner( p_dec );<br></div>
<div>+ vlc_mutex_lock( &p_owner->lock );<br></div>
<div>+ vout_thread_t *p_vout = p_owner->p_vout ? vlc_object_hold( p_owner->p_vout ) : NULL;<br></div>
<div>+ vlc_mutex_unlock( &p_owner->lock );<br></div>
<div>+ return p_vout;<br></div>
<div>+}<br></div>
<div>+<br></div>
<div> /**<br></div>
<div> * Load a decoder module<br></div>
<div> */<br></div>
<div>@@ -238,15 +257,17 @@ static int ReloadDecoder( decoder_t *p_dec, bool b_packetizer,<br></div>
<div> if( reload == RELOAD_DECODER_AOUT )<br></div>
<div> {<br></div>
<div> assert( p_owner->fmt.i_cat == AUDIO_ES );<br></div>
<div>- audio_output_t *p_aout = p_owner->p_aout;<br></div>
<div> <br></div>
<div> vlc_mutex_lock( &p_owner->lock );<br></div>
<div>+ audio_output_t *p_aout = p_owner->p_aout ? vlc_object_hold( p_owner->p_aout ) : NULL;<br></div>
<div> p_owner->p_aout = NULL;<br></div>
<div> vlc_mutex_unlock( &p_owner->lock );<br></div>
<div>+<br></div>
<div> if( p_aout )<br></div>
<div> {<br></div>
<div> aout_DecDelete( p_aout );<br></div>
<div> input_resource_PutAout( p_owner->p_resource, p_aout );<br></div>
<div>+ vlc_object_release( p_aout );<br></div>
<div> }<br></div>
<div> }<br></div>
<div> <br></div>
<div>@@ -1538,13 +1559,25 @@ static void *DecoderThread( void *p_data )<br></div>
<div> switch( p_dec->fmt_out.i_cat )<br></div>
<div> {<br></div>
<div> case VIDEO_ES:<br></div>
<div>- if( p_owner->p_vout != NULL )<br></div>
<div>- vout_ChangePause( p_owner->p_vout, paused, date );<br></div>
<div>+ {<br></div>
<div>+ vout_thread_t *p_vout = dec_get_vout( p_dec );<br></div>
<div>+ if( p_vout != NULL )<br></div>
<div>+ {<br></div>
<div>+ vout_ChangePause( p_vout, paused, date );<br></div>
<div>+ vlc_object_release( p_vout );<br></div>
<div>+ }<br></div>
<div> break;<br></div>
<div>+ }<br></div>
<div> case AUDIO_ES:<br></div>
<div>- if( p_owner->p_aout != NULL )<br></div>
<div>- aout_DecChangePause( p_owner->p_aout, paused, date );<br></div>
<div>+ {<br></div>
<div>+ audio_output_t *p_aout = dec_get_aout( p_dec );<br></div>
<div>+ if( p_aout != NULL )<br></div>
<div>+ {<br></div>
<div>+ aout_DecChangePause( p_aout, paused, date );<br></div>
<div>+ vlc_object_release( p_aout );<br></div>
<div>+ }<br></div>
<div> break;<br></div>
<div>+ }<br></div>
<div> case SPU_ES:<br></div>
<div> break;<br></div>
<div> default:<br></div>
<div>@@ -1569,9 +1602,15 @@ static void *DecoderThread( void *p_data )<br></div>
<div> case VIDEO_ES:<br></div>
<div> break;<br></div>
<div> case AUDIO_ES:<br></div>
<div>- if( p_owner->p_aout != NULL )<br></div>
<div>- aout_DecChangeRate( p_owner->p_aout, rate );<br></div>
<div>+ {<br></div>
<div>+ audio_output_t *p_aout = dec_get_aout( p_dec );<br></div>
<div>+ if( p_aout != NULL )<br></div>
<div>+ {<br></div>
<div>+ aout_DecChangeRate( p_aout, rate );<br></div>
<div>+ vlc_object_release( p_aout );<br></div>
<div>+ }<br></div>
<div> break;<br></div>
<div>+ }<br></div>
<div> case SPU_ES:<br></div>
<div> break;<br></div>
<div> default:<br></div>
</pre></blockquote></div>
<div><br></div>
<div>--<br></div>
<div> Envoyé de mon appareil Android avec Courriel K-9 Mail. Veuillez excuser ma brièveté. <br></div>
<div><u>_______________________________________________</u><br></div>
<div>vlc-devel mailing list<br></div>
<div>To unsubscribe or modify your subscription options:<br></div>
<div><a href="https://mailman.videolan.org/listinfo/vlc-devel">https://mailman.videolan.org/listinfo/vlc-devel</a><br></div>
</blockquote><div><br></div>
</body>
</html>