[vlc-commits] decoder: reduce lock scope and cosmetic
Rémi Denis-Courmont
git at videolan.org
Sat Mar 21 21:28:42 CET 2015
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sat Mar 21 22:19:13 2015 +0200| [0902f0d622730c1ec62483e419066e059ba6f000] | committer: Rémi Denis-Courmont
decoder: reduce lock scope and cosmetic
p_owner->b_paused can only be written by the owner, so the owner thread
does not need to lock to read it. (However, locking is necessary to
write it from the owner thread, or to read it from the decoder thread.)
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=0902f0d622730c1ec62483e419066e059ba6f000
---
src/input/decoder.c | 45 +++++++++++++++++++++++----------------------
1 file changed, 23 insertions(+), 22 deletions(-)
diff --git a/src/input/decoder.c b/src/input/decoder.c
index a399b25..d1da222 100644
--- a/src/input/decoder.c
+++ b/src/input/decoder.c
@@ -2056,30 +2056,31 @@ void input_DecoderChangePause( decoder_t *p_dec, bool b_paused, mtime_t i_date )
{
decoder_owner_sys_t *p_owner = p_dec->p_owner;
- vlc_mutex_lock( &p_owner->lock );
/* Normally, p_owner->b_paused != b_paused here. But if a track is added
* while the input is paused (e.g. add sub file), then b_paused is
- * (incorrectly) false. */
- if( likely(p_owner->b_paused != b_paused) ) {
- p_owner->b_paused = b_paused;
- p_owner->pause.i_date = i_date;
- p_owner->pause.i_ignore = 0;
- vlc_cond_signal( &p_owner->wait_request );
-
- /* XXX only audio and video output have to be paused.
- * - for sout it is useless
- * - for subs, it is done by the vout
- */
- if( p_owner->fmt.i_cat == AUDIO_ES )
- {
- if( p_owner->p_aout )
- aout_DecChangePause( p_owner->p_aout, b_paused, i_date );
- }
- else if( p_owner->fmt.i_cat == VIDEO_ES )
- {
- if( p_owner->p_vout )
- vout_ChangePause( p_owner->p_vout, b_paused, i_date );
- }
+ * (incorrectly) false. FIXME: This is a bug in the decoder owner. */
+ if( unlikely(p_owner->b_paused == b_paused) )
+ return;
+
+ vlc_mutex_lock( &p_owner->lock );
+ p_owner->b_paused = b_paused;
+ p_owner->pause.i_date = i_date;
+ p_owner->pause.i_ignore = 0;
+ vlc_cond_signal( &p_owner->wait_request );
+
+ /* XXX only audio and video output have to be paused.
+ * - for sout it is useless
+ * - for subs, it is done by the vout
+ */
+ if( p_owner->fmt.i_cat == AUDIO_ES )
+ {
+ if( p_owner->p_aout )
+ aout_DecChangePause( p_owner->p_aout, b_paused, i_date );
+ }
+ else if( p_owner->fmt.i_cat == VIDEO_ES )
+ {
+ if( p_owner->p_vout )
+ vout_ChangePause( p_owner->p_vout, b_paused, i_date );
}
vlc_mutex_unlock( &p_owner->lock );
}
More information about the vlc-commits
mailing list