[vlc-devel] [PATCH] decoder: avoid locking the owner if the format didn't change
Steve Lhomme
robux4 at ycbcr.xyz
Mon Jan 14 16:21:48 CET 2019
---
src/input/decoder.c | 15 ++++++++-------
1 file changed, 8 insertions(+), 7 deletions(-)
diff --git a/src/input/decoder.c b/src/input/decoder.c
index da83cf1b9f..1c14babcaa 100644
--- a/src/input/decoder.c
+++ b/src/input/decoder.c
@@ -89,7 +89,7 @@ struct decoder_owner
es_format_t fmt;
/* */
- bool b_fmt_description;
+ atomic_bool b_fmt_description;
vlc_meta_t *p_description;
atomic_int reload;
@@ -284,7 +284,7 @@ static void DecoderUpdateFormatLocked( decoder_t *p_dec )
p_dec->p_description = NULL;
}
- p_owner->b_fmt_description = true;
+ atomic_store( &p_owner->b_fmt_description, true);
}
static void MouseEvent( const vlc_mouse_t *newmouse, void *user_data )
@@ -1875,7 +1875,7 @@ static decoder_t * CreateDecoder( vlc_object_t *p_parent,
p_owner->p_sout_input = NULL;
p_owner->p_packetizer = NULL;
- p_owner->b_fmt_description = false;
+ atomic_init( &p_owner->b_fmt_description, false );
p_owner->p_description = NULL;
p_owner->reset_out_state = false;
@@ -2574,9 +2574,11 @@ bool input_DecoderHasFormatChanged( decoder_t *p_dec, es_format_t *p_fmt, vlc_me
struct decoder_owner *p_owner = dec_get_owner( p_dec );
bool b_changed;
- vlc_mutex_lock( &p_owner->lock );
b_changed = p_owner->b_fmt_description;
- if( b_changed )
+ if( !atomic_exchange( &p_owner->b_fmt_description, false ) )
+ return false;
+
+ vlc_mutex_lock( &p_owner->lock );
{
if( p_fmt != NULL )
es_format_Copy( p_fmt, &p_owner->fmt );
@@ -2591,10 +2593,9 @@ bool input_DecoderHasFormatChanged( decoder_t *p_dec, es_format_t *p_fmt, vlc_me
vlc_meta_Merge( *pp_meta, p_owner->p_description );
}
}
- p_owner->b_fmt_description = false;
}
vlc_mutex_unlock( &p_owner->lock );
- return b_changed;
+ return true;
}
size_t input_DecoderGetFifoSize( decoder_t *p_dec )
--
2.17.1
More information about the vlc-devel
mailing list