[vlc-commits] interrupt: add internal vlc_interrupt_get() helper

Rémi Denis-Courmont git at videolan.org
Mon Dec 21 19:56:04 CET 2015


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Mon Dec 21 20:48:58 2015 +0200| [4a9086ff38516208a966578ff8fe3fa703165010] | committer: Rémi Denis-Courmont

interrupt: add internal vlc_interrupt_get() helper

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=4a9086ff38516208a966578ff8fe3fa703165010
---

 src/misc/interrupt.c |   25 +++++++++++++++----------
 1 file changed, 15 insertions(+), 10 deletions(-)

diff --git a/src/misc/interrupt.c b/src/misc/interrupt.c
index 6560ba1..b78f8b0 100644
--- a/src/misc/interrupt.c
+++ b/src/misc/interrupt.c
@@ -150,6 +150,11 @@ vlc_interrupt_t *vlc_interrupt_set(vlc_interrupt_t *newctx)
     return oldctx;
 }
 
+static vlc_interrupt_t *vlc_interrupt_get(void)
+{
+    return vlc_threadvar_get(vlc_interrupt_var);
+}
+
 /**
  * Prepares to enter interruptible wait.
  * @param cb callback to interrupt the wait (i.e. wake up the thread)
@@ -161,7 +166,7 @@ static void vlc_interrupt_prepare(vlc_interrupt_t *ctx,
                                   void (*cb)(void *), void *data)
 {
     assert(ctx != NULL);
-    assert(ctx == vlc_threadvar_get(vlc_interrupt_var));
+    assert(ctx == vlc_interrupt_get());
 
     vlc_mutex_lock(&ctx->lock);
     assert(ctx->callback == NULL);
@@ -189,7 +194,7 @@ static int vlc_interrupt_finish(vlc_interrupt_t *ctx)
     int ret = 0;
 
     assert(ctx != NULL);
-    assert(ctx == vlc_threadvar_get(vlc_interrupt_var));
+    assert(ctx == vlc_interrupt_get());
 
     /* Wait for pending callbacks to prevent access by other threads. */
     vlc_mutex_lock(&ctx->lock);
@@ -205,14 +210,14 @@ static int vlc_interrupt_finish(vlc_interrupt_t *ctx)
 
 void vlc_interrupt_register(void (*cb)(void *), void *opaque)
 {
-    vlc_interrupt_t *ctx = vlc_threadvar_get(vlc_interrupt_var);
+    vlc_interrupt_t *ctx = vlc_interrupt_get();
     if (ctx != NULL)
         vlc_interrupt_prepare(ctx, cb, opaque);
 }
 
 int vlc_interrupt_unregister(void)
 {
-    vlc_interrupt_t *ctx = vlc_threadvar_get(vlc_interrupt_var);
+    vlc_interrupt_t *ctx = vlc_interrupt_get();
     return (ctx != NULL) ? vlc_interrupt_finish(ctx) : 0;
 }
 
@@ -231,7 +236,7 @@ void vlc_interrupt_kill(vlc_interrupt_t *ctx)
 
 bool vlc_killed(void)
 {
-    vlc_interrupt_t *ctx = vlc_threadvar_get(vlc_interrupt_var);
+    vlc_interrupt_t *ctx = vlc_interrupt_get();
 
     return (ctx != NULL) && atomic_load(&ctx->killed);
 }
@@ -243,7 +248,7 @@ static void vlc_interrupt_sem(void *opaque)
 
 int vlc_sem_wait_i11e(vlc_sem_t *sem)
 {
-    vlc_interrupt_t *ctx = vlc_threadvar_get(vlc_interrupt_var);
+    vlc_interrupt_t *ctx = vlc_interrupt_get();
     if (ctx == NULL)
         return vlc_sem_wait(sem), 0;
 
@@ -273,7 +278,7 @@ static void vlc_mwait_i11e_cleanup(void *opaque)
 
 int vlc_mwait_i11e(mtime_t deadline)
 {
-    vlc_interrupt_t *ctx = vlc_threadvar_get(vlc_interrupt_var);
+    vlc_interrupt_t *ctx = vlc_interrupt_get();
     if (ctx == NULL)
         return mwait(deadline), 0;
 
@@ -308,7 +313,7 @@ void vlc_interrupt_forward_start(vlc_interrupt_t *to, void *data[2])
 {
     data[0] = data[1] = NULL;
 
-    vlc_interrupt_t *from = vlc_threadvar_get(vlc_interrupt_var);
+    vlc_interrupt_t *from = vlc_interrupt_get();
     if (from == NULL)
         return;
 
@@ -417,7 +422,7 @@ static int vlc_poll_i11e_inner(struct pollfd *restrict fds, unsigned nfds,
 
 int vlc_poll_i11e(struct pollfd *fds, unsigned nfds, int timeout)
 {
-    vlc_interrupt_t *ctx = vlc_threadvar_get(vlc_interrupt_var);
+    vlc_interrupt_t *ctx = vlc_interrupt_get();
     if (ctx == NULL)
         return poll(fds, nfds, timeout);
 
@@ -614,7 +619,7 @@ static void vlc_poll_i11e_cleanup(void *opaque)
 
 int vlc_poll_i11e(struct pollfd *fds, unsigned nfds, int timeout)
 {
-    vlc_interrupt_t *ctx = vlc_threadvar_get(vlc_interrupt_var);
+    vlc_interrupt_t *ctx = vlc_interrupt_get();
     if (ctx == NULL)
         return vlc_poll(fds, nfds, timeout);
 



More information about the vlc-commits mailing list