int vlc_mwait_i11e(mtime_t deadline) { vlc_interrupt_t *ctx = vlc_threadvar_get(vlc_interrupt_var); if (ctx == NULL) return mwait(deadline), 0; vlc_cond_t wait; vlc_cond_init(&wait); int ret = vlc_interrupt_prepare(ctx, vlc_mwait_i11e_wake, &wait); if (ret) { vlc_cond_destroy(&wait); vlc_testcancel(); return ret; } vlc_mutex_lock(&ctx->lock); vlc_cleanup_push(vlc_mwait_i11e_cleanup, ctx); while (!ctx->interrupted && vlc_cond_timedwait(&wait, &ctx->lock, deadline) == 0); vlc_cleanup_pop(); vlc_mutex_unlock(&ctx->lock); ret = vlc_interrupt_finish(ctx); vlc_cond_destroy(&wait); return ret; }
void vlc_interrupt_forward_start(vlc_interrupt_t *to, void *data[2]) { data[0] = data[1] = NULL; vlc_interrupt_t *from = vlc_interrupt_get(); if (from == NULL) return; assert(from != to); data[0] = to; data[1] = from; vlc_interrupt_prepare(from, vlc_interrupt_forward_wake, data); }
int vlc_sem_wait_i11e(vlc_sem_t *sem) { vlc_interrupt_t *ctx = vlc_interrupt_get(); if (ctx == NULL) return vlc_sem_wait(sem), 0; vlc_interrupt_prepare(ctx, vlc_interrupt_sem, sem); vlc_cleanup_push(vlc_interrupt_cleanup, ctx); vlc_sem_wait(sem); vlc_cleanup_pop(); return vlc_interrupt_finish(ctx); }
int vlc_sem_wait_i11e(vlc_sem_t *sem) { vlc_interrupt_t *ctx = vlc_threadvar_get(vlc_interrupt_var); if (ctx == NULL) return vlc_sem_wait(sem), 0; int ret = vlc_interrupt_prepare(ctx, vlc_interrupt_sem, sem); if (ret) { vlc_testcancel(); return ret; } vlc_cleanup_push(vlc_interrupt_cleanup, ctx); vlc_sem_wait(sem); vlc_cleanup_pop(); return vlc_interrupt_finish(ctx); }
void vlc_interrupt_register(void (*cb)(void *), void *opaque) { vlc_interrupt_t *ctx = vlc_interrupt_get(); if (ctx != NULL) vlc_interrupt_prepare(ctx, cb, opaque); }