END_TEST START_TEST (test_mutex_lock_null) { OMX_ERRORTYPE error = tiz_mutex_lock (0); (void)error; }
static OMX_ERRORTYPE _ctx_wait (cc_ctx_t * app_ctx, OMX_U32 a_millis, OMX_BOOL * ap_has_timedout) { int retcode; check_common_context_t *p_ctx = NULL; assert (app_ctx); p_ctx = * app_ctx; TIZ_LOG (TIZ_TRACE, "a_millis [%u]", a_millis); * ap_has_timedout = OMX_FALSE; if (tiz_mutex_lock (&p_ctx->mutex)) { return OMX_ErrorBadParameter; } if (0 == a_millis) { if (!p_ctx->signaled) { * ap_has_timedout = OMX_TRUE; } } else if (INFINITE_WAIT == a_millis) { while (!p_ctx->signaled) { tiz_cond_wait (&p_ctx->cond, &p_ctx->mutex); } } else { while (!p_ctx->signaled) { retcode = tiz_cond_timedwait (&p_ctx->cond, &p_ctx->mutex, a_millis); /* TODO: Change this to OMX_ErrorTimeout */ if (retcode == OMX_ErrorUndefined && !p_ctx->signaled) { * ap_has_timedout = OMX_TRUE; break; } } } tiz_mutex_unlock (&p_ctx->mutex); return OMX_ErrorNone; }
END_TEST START_TEST (test_mutex_lock_and_unlock) { OMX_ERRORTYPE error = OMX_ErrorNone; tiz_mutex_t mutex; error = tiz_mutex_init (&mutex); fail_if (error != OMX_ErrorNone); tiz_mutex_lock (&mutex); tiz_mutex_unlock (&mutex); tiz_mutex_destroy (&mutex); }
static OMX_ERRORTYPE _ctx_reset (cc_ctx_t * app_ctx) { check_common_context_t *p_ctx = NULL; assert (app_ctx); p_ctx = * app_ctx; if (tiz_mutex_lock (&p_ctx->mutex)) { return OMX_ErrorBadParameter; } p_ctx->signaled = OMX_FALSE; tiz_mutex_unlock (&p_ctx->mutex); return OMX_ErrorNone; }
static OMX_ERRORTYPE _ctx_reset (cc_ctx_t * app_ctx, OMX_EVENTTYPE event) { check_common_context_t *p_ctx = NULL; assert (app_ctx); assert (-1 != event2signal(event)); p_ctx = * app_ctx; if (tiz_mutex_lock (&p_ctx->mutex)) { return OMX_ErrorBadParameter; } TIZ_LOG (TIZ_PRIORITY_TRACE, "Resetting [%s] event [%s] ", ctx2cname(p_ctx), tiz_evt_to_str(event)); p_ctx->signaled[event2signal(event)] = OMX_FALSE; p_ctx->event[event2signal(event)] = OMX_EventMax; if (OMX_EventCmdComplete == event) { p_ctx->state = OMX_StateMax; } if (OMX_EventVendorStartUnused == event) { p_ctx->p_hdr = NULL; } if (OMX_EventBufferFlag == event) { p_ctx->flags = 0; } if (OMX_EventPortSettingsChanged == event) { p_ctx->port = 0; p_ctx->index = 0; } tiz_mutex_unlock (&p_ctx->mutex); return OMX_ErrorNone; }
static OMX_ERRORTYPE _ctx_destroy (cc_ctx_t * app_ctx) { check_common_context_t *p_ctx = NULL; assert (app_ctx); p_ctx = * app_ctx; if (tiz_mutex_lock (&p_ctx->mutex)) { return OMX_ErrorBadParameter; } tiz_cond_destroy (&p_ctx->cond); tiz_mutex_unlock (&p_ctx->mutex); tiz_mutex_destroy (&p_ctx->mutex); tiz_mem_free (p_ctx); return OMX_ErrorNone; }
static OMX_ERRORTYPE _ctx_signal (cc_ctx_t * app_ctx, OMX_EVENTTYPE event) { check_common_context_t *p_ctx = NULL; assert (app_ctx); assert (-1 != event2signal(event)); p_ctx = * app_ctx; if (tiz_mutex_lock (&p_ctx->mutex)) { return OMX_ErrorBadParameter; } TIZ_LOG (TIZ_PRIORITY_TRACE, "Context [%s] has been signalled [%s]", ctx2cname(p_ctx), tiz_evt_to_str(event)); p_ctx->signaled[event2signal(event)] = OMX_TRUE; p_ctx->event[event2signal(event)] = event; tiz_cond_signal (&p_ctx->cond); tiz_mutex_unlock (&p_ctx->mutex); return OMX_ErrorNone; }
static OMX_ERRORTYPE _ctx_wait (cc_ctx_t * app_ctx, OMX_EVENTTYPE event, OMX_U32 a_millis, OMX_BOOL * ap_has_timedout) { OMX_ERRORTYPE retcode = OMX_ErrorNone; check_common_context_t *p_ctx = NULL; assert (app_ctx); assert (-1 != event2signal(event)); p_ctx = * app_ctx; * ap_has_timedout = OMX_FALSE; if (tiz_mutex_lock (&p_ctx->mutex)) { return OMX_ErrorBadParameter; } TIZ_LOG (TIZ_PRIORITY_TRACE, "Waiting for [%s] a_millis [%u] signaled [%s]", ctx2cname(p_ctx), a_millis, p_ctx->signaled[event2signal(event)] ? "OMX_TRUE" : "OMX_FALSE"); if (0 == a_millis) { if (!p_ctx->signaled[event2signal(event)]) { * ap_has_timedout = OMX_TRUE; } } else if (INFINITE_WAIT == a_millis) { while (!p_ctx->signaled[event2signal(event)]) { tiz_cond_wait (&p_ctx->cond, &p_ctx->mutex); } } else { while (!p_ctx->signaled[event2signal(event)]) { retcode = tiz_cond_timedwait (&p_ctx->cond, &p_ctx->mutex, a_millis); /* TODO: Change this to OMX_ErrorTimeout */ if (retcode == OMX_ErrorUndefined && !p_ctx->signaled[event2signal(event)]) { TIZ_LOG (TIZ_PRIORITY_TRACE, "Waiting for [%s] - " "timeout occurred", ctx2cname(p_ctx)); * ap_has_timedout = OMX_TRUE; break; } } } tiz_mutex_unlock (&p_ctx->mutex); return OMX_ErrorNone; }