[vlc-devel] [PATCH 1/6] timer: add a macro to disarm a timer and a define for the disarm value
Steve Lhomme
robux4 at ycbcr.xyz
Thu Jul 5 15:41:03 CEST 2018
On 2018-07-05 15:22, Steve Lhomme wrote:
> ---
> include/vlc_threads.h | 4 ++++
> src/os2/thread.c | 2 +-
> src/posix/timer.c | 2 +-
> src/test/timer.c | 2 +-
> src/win32/timer.c | 2 +-
> 5 files changed, 8 insertions(+), 4 deletions(-)
>
> diff --git a/include/vlc_threads.h b/include/vlc_threads.h
> index f1343868a4..0b9de32fb9 100644
> --- a/include/vlc_threads.h
> +++ b/include/vlc_threads.h
> @@ -948,6 +948,8 @@ VLC_USED;
> */
> VLC_API void vlc_timer_destroy(vlc_timer_t timer);
>
> +#define VLC_TIMER_DISARM (0)
> +
> /**
> * Arms or disarms an initialized timer.
> *
> @@ -969,6 +971,8 @@ VLC_API void vlc_timer_destroy(vlc_timer_t timer);
> VLC_API void vlc_timer_schedule(vlc_timer_t timer, bool absolute,
> vlc_tick_t value, vlc_tick_t interval);
>
> +#define vlc_timer_disarm(timer) vlc_timer_schedule( timer, false, 0, 0 )
Missing VLC_TIMER_DISARMĀ here.
> +
> /**
> * Fetches and resets the overrun counter for a timer.
> *
> diff --git a/src/os2/thread.c b/src/os2/thread.c
> index b963b8893f..17d2e60aa2 100644
> --- a/src/os2/thread.c
> +++ b/src/os2/thread.c
> @@ -1010,7 +1010,7 @@ void vlc_timer_schedule (vlc_timer_t timer, bool absolute,
> timer->interval = 0;
> }
>
> - if (value == 0)
> + if (value == VLC_TIMER_DISARM)
> return; /* Disarm */
>
> if (absolute)
> diff --git a/src/posix/timer.c b/src/posix/timer.c
> index e806e85fec..9acd51db8f 100644
> --- a/src/posix/timer.c
> +++ b/src/posix/timer.c
> @@ -146,7 +146,7 @@ void vlc_timer_destroy (vlc_timer_t timer)
> void vlc_timer_schedule (vlc_timer_t timer, bool absolute,
> vlc_tick_t value, vlc_tick_t interval)
> {
> - if (value == 0)
> + if (value == VLC_TIMER_DISARM)
> interval = 0;
> else
> if (!absolute)
> diff --git a/src/test/timer.c b/src/test/timer.c
> index e287c1548e..539f8cd5c3 100644
> --- a/src/test/timer.c
> +++ b/src/test/timer.c
> @@ -87,7 +87,7 @@ int main (void)
> vlc_mutex_unlock (&data.lock);
> assert(ts >= VLC_TICK_FROM_MS(100));
>
> - vlc_timer_schedule (data.timer, false, 0, 0);
> + vlc_timer_disarm (data.timer);
>
> /* Absolute timer */
> ts = vlc_tick_now ();
> diff --git a/src/win32/timer.c b/src/win32/timer.c
> index 8a8d106183..4c118252bc 100644
> --- a/src/win32/timer.c
> +++ b/src/win32/timer.c
> @@ -70,7 +70,7 @@ void vlc_timer_schedule (vlc_timer_t timer, bool absolute,
> DeleteTimerQueueTimer (NULL, timer->handle, INVALID_HANDLE_VALUE);
> timer->handle = INVALID_HANDLE_VALUE;
> }
> - if (value == 0)
> + if (value == VLC_TIMER_DISARM)
> return; /* Disarm */
>
> if (absolute)
> --
> 2.17.0
>
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel
More information about the vlc-devel
mailing list