[vlc-devel] [PATCH] input: reduce the number of locks for every MainLoop cycle
Hugo Beauzée-Luyssen
hugo at beauzee.fr
Fri Dec 11 11:42:51 CET 2015
On 12/11/2015 11:36 AM, Steve Lhomme wrote:
> ---
> src/input/input.c | 7 +------
> src/input/input_internal.h | 2 +-
> 2 files changed, 2 insertions(+), 7 deletions(-)
>
> diff --git a/src/input/input.c b/src/input/input.c
> index a5d408c..a982fa7 100644
> --- a/src/input/input.c
> +++ b/src/input/input.c
> @@ -510,12 +510,7 @@ static void *Preparse( void *obj )
> bool input_Stopped( input_thread_t *input )
> {
> input_thread_private_t *sys = input->p;
> - bool ret;
> -
> - vlc_mutex_lock( &sys->lock_control );
> - ret = sys->is_stopped;
> - vlc_mutex_unlock( &sys->lock_control );
> - return ret;
> + return sys->is_stopped;
> }
>
> /*****************************************************************************
> diff --git a/src/input/input_internal.h b/src/input/input_internal.h
> index 249ef2e..1d35d94 100644
> --- a/src/input/input_internal.h
> +++ b/src/input/input_internal.h
> @@ -89,7 +89,7 @@ struct input_thread_private_t
> /* Current state */
> int i_state;
> bool is_running;
> - bool is_stopped;
> + atomic_bool is_stopped;
> bool b_recording;
> int i_rate;
>
>
That doesn't look good. You need to atomic_store/atomic_load this value.
atomic_bool is defined as such:
typedef bool atomic_bool;
meaning if you don't atomic_* it, you'll lose all the synchronization,
and will enter the realm of undefined behavior.
Regards,
More information about the vlc-devel
mailing list