<html><head></head><body>LGTM<br><br><div class="gmail_quote">Le 10 février 2020 15:39:10 GMT+02:00, Steve Lhomme <robux4@ycbcr.xyz> a écrit :<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<pre class="k9mail">Should only be called on Win32 and Android, the only platforms where<br>LIBVLC_NEED_CONDVAR is defined.<br><br>LIBVLC_NEED_SLEEP is always found when LIBVLC_NEED_CONDVAR is set, so no need<br>to test it.<hr> include/vlc_threads.h | 15 ++++--------<br> src/android/thread.c | 56 +++++++++++++++++++------------------------<br> src/win32/thread.c | 42 ++++++++++++++++----------------<br> 3 files changed, 50 insertions(+), 63 deletions(-)<br><br>diff --git a/include/vlc_threads.h b/include/vlc_threads.h<br>index 2e85d63d6be..0025ca7ea7d 100644<br>--- a/include/vlc_threads.h<br>+++ b/include/vlc_threads.h<br>@@ -1028,8 +1028,6 @@ enum<br> {<br> VLC_CLEANUP_PUSH,<br> VLC_CLEANUP_POP,<br>- VLC_CANCEL_ADDR_SET,<br>- VLC_CANCEL_ADDR_CLEAR,<br> };<br> <br> #if defined (LIBVLC_USE_PTHREAD_CLEANUP)<br>@@ -1100,15 +1098,10 @@ static inline void vlc_cleanup_lock (void *lock)<br> }<br> #define mutex_cleanup_push( lock ) vlc_cleanup_push (vlc_cleanup_lock, lock)<br> <br>-static inline void vlc_cancel_addr_set(void *addr)<br>-{<br>- vlc_control_cancel(VLC_CANCEL_ADDR_SET, addr);<br>-}<br>-<br>-static inline void vlc_cancel_addr_clear(void *addr)<br>-{<br>- vlc_control_cancel(VLC_CANCEL_ADDR_CLEAR, addr);<br>-}<br>+#if defined(LIBVLC_NEED_CONDVAR)<br>+void vlc_cancel_addr_set(void *addr);<br>+void vlc_cancel_addr_clear(void *addr);<br>+#endif<br> <br> #ifdef __cplusplus<br> /**<br>diff --git a/src/android/thread.c b/src/android/thread.c<br>index ca715418d41..c213e237ea4 100644<br>--- a/src/android/thread.c<br>+++ b/src/android/thread.c<br>@@ -34,6 +34,7 @@<br> #include <signal.h><br> #include <errno.h><br> #include <stdatomic.h><br>+#include <stdnoreturn.h><br> #include <time.h><br> #include <assert.h><br> <br>@@ -328,44 +329,35 @@ void vlc_testcancel (void)<br> pthread_exit(NULL);<br> }<br> <br>-void vlc_control_cancel(int cmd, ...)<br>+noreturn void vlc_control_cancel (int cmd, ...)<br>+{<br>+ (void) cmd;<br>+ vlc_assert_unreachable ();<br>+}<br>+<br>+void vlc_cancel_addr_set(void *addr)<br> {<br> vlc_thread_t th = vlc_thread_self();<br>- va_list ap;<br>+ if (th == NULL)<br>+ return;<br> <br>+ vlc_mutex_lock(&th->wait.lock);<br>+ assert(th->wait.addr == NULL);<br>+ th->wait.addr = addr;<br>+ vlc_mutex_unlock(&th->wait.lock);<br>+}<br>+<br>+void vlc_cancel_addr_clear(void *addr)<br>+{<br>+ vlc_thread_t th = vlc_thread_self();<br> if (th == NULL)<br> return;<br> <br>- va_start(ap, cmd);<br>- switch (cmd)<br>- {<br>- case VLC_CANCEL_ADDR_SET:<br>- {<br>- void *addr = va_arg(ap, void *);<br>-<br>- vlc_mutex_lock(&th->wait.lock);<br>- assert(th->wait.addr == NULL);<br>- th->wait.addr = addr;<br>- vlc_mutex_unlock(&th->wait.lock);<br>- break;<br>- }<br>-<br>- case VLC_CANCEL_ADDR_CLEAR:<br>- {<br>- void *addr = va_arg(ap, void *);<br>-<br>- vlc_mutex_lock(&th->wait.lock);<br>- assert(th->wait.addr == addr);<br>- th->wait.addr = NULL;<br>- (void) addr;<br>- vlc_mutex_unlock(&th->wait.lock);<br>- break;<br>- }<br>-<br>- default:<br>- vlc_assert_unreachable ();<br>- }<br>- va_end(ap);<br>+ vlc_mutex_lock(&th->wait.lock);<br>+ assert(th->wait.addr == addr);<br>+ th->wait.addr = NULL;<br>+ (void) addr;<br>+ vlc_mutex_unlock(&th->wait.lock);<br> }<br> <br> /* threadvar */<br>diff --git a/src/win32/thread.c b/src/win32/thread.c<br>index 6af2eb83852..23f9c0afe50 100644<br>--- a/src/win32/thread.c<br>+++ b/src/win32/thread.c<br>@@ -666,30 +666,32 @@ void vlc_control_cancel (int cmd, ...)<br> th->cleaners = th->cleaners->next;<br> break;<br> }<br>+ }<br>+ va_end (ap);<br>+}<br> <br>- case VLC_CANCEL_ADDR_SET:<br>- {<br>- void *addr = va_arg(ap, void *);<br>+void vlc_cancel_addr_set(void *addr)<br>+{<br>+ struct vlc_thread *th = vlc_thread_self();<br>+ if (th == NULL)<br>+ return; /* Main thread - cannot be cancelled anyway */<br> <br>- EnterCriticalSection(&th->wait.lock);<br>- assert(th->wait.addr == NULL);<br>- th->wait.addr = addr;<br>- LeaveCriticalSection(&th->wait.lock);<br>- break;<br>- }<br>+ EnterCriticalSection(&th->wait.lock);<br>+ assert(th->wait.addr == NULL);<br>+ th->wait.addr = addr;<br>+ LeaveCriticalSection(&th->wait.lock);<br>+}<br> <br>- case VLC_CANCEL_ADDR_CLEAR:<br>- {<br>- void *addr = va_arg(ap, void *);<br>+void vlc_cancel_addr_clear(void *addr)<br>+{<br>+ struct vlc_thread *th = vlc_thread_self();<br>+ if (th == NULL)<br>+ return; /* Main thread - cannot be cancelled anyway */<br> <br>- EnterCriticalSection(&th->wait.lock);<br>- assert(th->wait.addr == addr);<br>- th->wait.addr = NULL;<br>- LeaveCriticalSection(&th->wait.lock);<br>- break;<br>- }<br>- }<br>- va_end (ap);<br>+ EnterCriticalSection(&th->wait.lock);<br>+ assert(th->wait.addr == addr);<br>+ th->wait.addr = NULL;<br>+ LeaveCriticalSection(&th->wait.lock);<br> }<br> <br> /*** Clock ***/</pre></blockquote></div><br>-- <br>Envoyé de mon appareil Android avec Courriel K-9 Mail. Veuillez excuser ma brièveté.</body></html>