[vlc-commits] decoder: convert drained flag to atomic
Rémi Denis-Courmont
git at videolan.org
Sat Nov 7 12:56:48 CET 2015
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sat Nov 7 13:28:09 2015 +0200| [25e55831369ff4c017b4cd5980a5a97cd921cb41] | committer: Rémi Denis-Courmont
decoder: convert drained flag to atomic
So long as the flag is only polled, this is a little bit simpler.
(Though ideally, it would probably not be polled.)
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=25e55831369ff4c017b4cd5980a5a97cd921cb41
---
src/input/decoder.c | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/src/input/decoder.c b/src/input/decoder.c
index 8206dee..8f0ef22 100644
--- a/src/input/decoder.c
+++ b/src/input/decoder.c
@@ -112,7 +112,7 @@ struct decoder_owner_sys_t
bool flushed;
bool b_flushing;
bool b_draining;
- bool b_drained;
+ atomic_bool drained;
bool b_idle;
/* CC */
@@ -1521,8 +1521,11 @@ static void *DecoderThread( void *p_data )
}
vlc_restorecancel( canc );
+ /* Given that the drained flag is only polled, an atomic variable is
+ * sufficient. TODO? Wait for draining instead of polling. */
+ atomic_store( &p_owner->drained, (p_block == NULL) );
+
vlc_mutex_lock( &p_owner->lock );
- p_owner->b_drained = (p_block == NULL);
vlc_fifo_Lock( p_owner->p_fifo );
vlc_cond_signal( &p_owner->wait_acknowledge );
vlc_mutex_unlock( &p_owner->lock );
@@ -1588,7 +1591,7 @@ static decoder_t * CreateDecoder( vlc_object_t *p_parent,
p_owner->flushed = true;
p_owner->b_flushing = false;
p_owner->b_draining = false;
- p_owner->b_drained = false;
+ atomic_init( &p_owner->drained, false );
p_owner->b_idle = false;
es_format_Init( &p_owner->fmt, UNKNOWN_ES, 0 );
@@ -1939,7 +1942,7 @@ bool input_DecoderIsEmpty( decoder_t * p_dec )
if( p_owner->fmt.i_cat == VIDEO_ES && p_owner->p_vout != NULL )
b_empty = vout_IsEmpty( p_owner->p_vout );
else if( p_owner->fmt.i_cat == AUDIO_ES )
- b_empty = p_owner->b_drained;
+ b_empty = atomic_load( &p_owner->drained );
else
b_empty = true; /* TODO subtitles support */
vlc_mutex_unlock( &p_owner->lock );
More information about the vlc-commits
mailing list