static int init_control(void);
-static struct ilm_control_context* get_instance(void);
+static struct ilm_control_context* sync_and_acquire_instance(void);
static int create_controller_layer(struct wayland_context *ctx, t_ilm_uint width, t_ilm_uint height, t_ilm_layer layerid);
}
static struct ilm_control_context*
-get_instance(void)
+sync_and_acquire_instance(void)
{
struct ilm_control_context *ctx = &ilm_context;
lock_context(ctx);
display_roundtrip_queue(ctx->main_ctx.display, ctx->main_ctx.queue);
- unlock_context(ctx);
return ctx;
}
+static void release_instance(void)
+{
+ struct ilm_control_context *ctx = &ilm_context;
+ unlock_context(ctx);
+}
+
static uint32_t
gen_layer_id(struct ilm_control_context *ctx)
{
struct ilmLayerProperties* pLayerProperties)
{
ilmErrorTypes returnValue = ILM_FAILED;
- struct ilm_control_context *ctx = get_instance();
- lock_context(ctx);
+ struct ilm_control_context *ctx = sync_and_acquire_instance();
struct layer_context *ctx_layer = NULL;
if (pLayerProperties != NULL) {
}
}
- unlock_context(ctx);
+ release_instance();
return returnValue;
}
struct ilmScreenProperties* pScreenProperties)
{
ilmErrorTypes returnValue = ILM_FAILED;
- struct ilm_control_context *ctx = get_instance();
- lock_context(ctx);
+ struct ilm_control_context *ctx = sync_and_acquire_instance();
if (pScreenProperties != NULL) {
struct screen_context *ctx_screen = NULL;
pScreenProperties->screenHeight = 0;
}
- unlock_context(ctx);
+ release_instance();
return returnValue;
}
wayland_getScreenIDs(t_ilm_uint* pNumberOfIDs, t_ilm_uint** ppIDs)
{
ilmErrorTypes returnValue = ILM_FAILED;
- struct ilm_control_context *ctx = get_instance();
- lock_context(ctx);
+ struct ilm_control_context *ctx = sync_and_acquire_instance();
if ((pNumberOfIDs != NULL) && (ppIDs != NULL)) {
struct screen_context *ctx_scrn = NULL;
}
}
- unlock_context(ctx);
+ release_instance();
return returnValue;
}
wayland_getLayerIDs(t_ilm_int* pLength, t_ilm_layer** ppArray)
{
ilmErrorTypes returnValue = ILM_FAILED;
- struct ilm_control_context *ctx = get_instance();
- lock_context(ctx);
+ struct ilm_control_context *ctx = sync_and_acquire_instance();
if ((pLength != NULL) && (ppArray != NULL)) {
struct layer_context *ctx_layer = NULL;
}
}
- unlock_context(ctx);
+ release_instance();
return returnValue;
}
t_ilm_layer** ppArray)
{
ilmErrorTypes returnValue = ILM_FAILED;
- struct ilm_control_context *ctx = get_instance();
- lock_context(ctx);
+ struct ilm_control_context *ctx = sync_and_acquire_instance();
if ((pLength != NULL) && (ppArray != NULL)) {
struct screen_context *ctx_screen = NULL;
}
}
- unlock_context(ctx);
+ release_instance();
return returnValue;
}
wayland_getSurfaceIDs(t_ilm_int* pLength, t_ilm_surface** ppArray)
{
ilmErrorTypes returnValue = ILM_FAILED;
- struct ilm_control_context *ctx = get_instance();
- lock_context(ctx);
+ struct ilm_control_context *ctx = sync_and_acquire_instance();
if ((pLength != NULL) && (ppArray != NULL)) {
struct surface_context *ctx_surf = NULL;
}
}
- unlock_context(ctx);
+ release_instance();
return returnValue;
}
t_ilm_int* pLength,
t_ilm_surface** ppArray)
{
- struct ilm_control_context *ctx = get_instance();
- lock_context(ctx);
+ struct ilm_control_context *ctx = sync_and_acquire_instance();
struct layer_context *ctx_layer = NULL;
struct surface_context *ctx_surf = NULL;
t_ilm_uint length = 0;
t_ilm_surface* ids = NULL;
if ((pLength == NULL) || (ppArray == NULL)) {
- unlock_context(ctx);
+ release_instance();
return ILM_FAILED;
}
&ctx->main_ctx, (uint32_t)layer);
if (ctx_layer == NULL) {
- unlock_context(ctx);
+ release_instance();
return ILM_FAILED;
}
length = wl_list_length(&ctx_layer->order.list_surface);
*ppArray = (t_ilm_surface*)malloc(length * sizeof *ppArray);
if (*ppArray == NULL) {
- unlock_context(ctx);
+ release_instance();
return ILM_FAILED;
}
}
*pLength = length;
- unlock_context(ctx);
+ release_instance();
return ILM_SUCCESS;
}
t_ilm_uint height)
{
ilmErrorTypes returnValue = ILM_FAILED;
- struct ilm_control_context *ctx = get_instance();
- lock_context(ctx);
+ struct ilm_control_context *ctx = sync_and_acquire_instance();
uint32_t layerid = 0;
int32_t is_inside = 0;
}
} while(0);
- unlock_context(ctx);
+ release_instance();
return returnValue;
}
wayland_layerRemove(t_ilm_layer layerId)
{
ilmErrorTypes returnValue = ILM_FAILED;
- struct ilm_control_context *ctx = get_instance();
- lock_context(ctx);
+ struct ilm_control_context *ctx = sync_and_acquire_instance();
struct layer_context *ctx_layer = NULL;
struct layer_context *ctx_next = NULL;
}
}
- unlock_context(ctx);
+ release_instance();
return returnValue;
}
return ILM_ERROR_INVALID_ARGUMENTS;
}
- struct ilm_control_context *ctx = get_instance();
- lock_context(ctx);
+ struct ilm_control_context *ctx = sync_and_acquire_instance();
*pLayerType = wayland_controller_is_inside_layer_list(&ctx->main_ctx.list_layer, layerId) ?
ILM_LAYERTYPE_SOFTWARE2D :
ILM_LAYERTYPE_UNKNOWN;
- unlock_context(ctx);
+ release_instance();
return ILM_SUCCESS; // even if non existent?
}
wayland_layerSetVisibility(t_ilm_layer layerId, t_ilm_bool newVisibility)
{
ilmErrorTypes returnValue = ILM_FAILED;
- struct ilm_control_context *ctx = get_instance();
- lock_context(ctx);
+ struct ilm_control_context *ctx = sync_and_acquire_instance();
struct layer_context *ctx_layer = NULL;
ctx_layer = (struct layer_context*)wayland_controller_get_layer_context(
returnValue = ILM_SUCCESS;
}
- unlock_context(ctx);
+ release_instance();
return returnValue;
}
wayland_layerGetVisibility(t_ilm_layer layerId, t_ilm_bool *pVisibility)
{
ilmErrorTypes returnValue = ILM_FAILED;
- struct ilm_control_context *ctx = get_instance();
- lock_context(ctx);
+ struct ilm_control_context *ctx = sync_and_acquire_instance();
if (pVisibility != NULL) {
struct layer_context *ctx_layer = NULL;
}
}
- unlock_context(ctx);
+ release_instance();
return returnValue;
}
wayland_layerSetOpacity(t_ilm_layer layerId, t_ilm_float opacity)
{
ilmErrorTypes returnValue = ILM_FAILED;
- struct ilm_control_context *ctx = get_instance();
- lock_context(ctx);
+ struct ilm_control_context *ctx = sync_and_acquire_instance();
struct layer_context *ctx_layer = NULL;
ctx_layer = (struct layer_context*)wayland_controller_get_layer_context(
returnValue = ILM_SUCCESS;
}
- unlock_context(ctx);
+ release_instance();
return returnValue;
}
wayland_layerGetOpacity(t_ilm_layer layerId, t_ilm_float *pOpacity)
{
ilmErrorTypes returnValue = ILM_FAILED;
- struct ilm_control_context *ctx = get_instance();
- lock_context(ctx);
+ struct ilm_control_context *ctx = sync_and_acquire_instance();
if (pOpacity != NULL) {
struct layer_context *ctx_layer = NULL;
}
}
- unlock_context(ctx);
+ release_instance();
return returnValue;
}
t_ilm_uint width, t_ilm_uint height)
{
ilmErrorTypes returnValue = ILM_FAILED;
- struct ilm_control_context *ctx = get_instance();
- lock_context(ctx);
+ struct ilm_control_context *ctx = sync_and_acquire_instance();
struct layer_context *ctx_layer = NULL;
ctx_layer = (struct layer_context*)wayland_controller_get_layer_context(
returnValue = ILM_SUCCESS;
}
- unlock_context(ctx);
+ release_instance();
return returnValue;
}
t_ilm_int width, t_ilm_int height)
{
ilmErrorTypes returnValue = ILM_FAILED;
- struct ilm_control_context *ctx = get_instance();
- lock_context(ctx);
+ struct ilm_control_context *ctx = sync_and_acquire_instance();
struct layer_context *ctx_layer = NULL;
ctx_layer = (struct layer_context*)wayland_controller_get_layer_context(
returnValue = ILM_SUCCESS;
}
- unlock_context(ctx);
+ release_instance();
return returnValue;
}
wayland_layerGetDimension(t_ilm_layer layerId, t_ilm_uint *pDimension)
{
ilmErrorTypes returnValue = ILM_FAILED;
- struct ilm_control_context *ctx = get_instance();
- lock_context(ctx);
+ struct ilm_control_context *ctx = sync_and_acquire_instance();
struct layer_context *ctx_layer = NULL;
if (pDimension != NULL) {
}
}
- unlock_context(ctx);
+ release_instance();
return returnValue;
}
wayland_layerSetDimension(t_ilm_layer layerId, t_ilm_uint *pDimension)
{
ilmErrorTypes returnValue = ILM_FAILED;
- struct ilm_control_context *ctx = get_instance();
- lock_context(ctx);
+ struct ilm_control_context *ctx = sync_and_acquire_instance();
struct layer_context *ctx_layer = NULL;
if (pDimension != NULL) {
}
}
- unlock_context(ctx);
+ release_instance();
return returnValue;
}
wayland_layerGetPosition(t_ilm_layer layerId, t_ilm_uint *pPosition)
{
ilmErrorTypes returnValue = ILM_FAILED;
- struct ilm_control_context *ctx = get_instance();
- lock_context(ctx);
+ struct ilm_control_context *ctx = sync_and_acquire_instance();
struct layer_context *ctx_layer = NULL;
if (pPosition != NULL) {
}
}
- unlock_context(ctx);
+ release_instance();
return returnValue;
}
wayland_layerSetPosition(t_ilm_layer layerId, t_ilm_uint *pPosition)
{
ilmErrorTypes returnValue = ILM_FAILED;
- struct ilm_control_context *ctx = get_instance();
- lock_context(ctx);
+ struct ilm_control_context *ctx = sync_and_acquire_instance();
struct layer_context *ctx_layer = NULL;
if (pPosition != NULL) {
}
}
- unlock_context(ctx);
+ release_instance();
return returnValue;
}
wayland_layerSetOrientation(t_ilm_layer layerId, ilmOrientation orientation)
{
ilmErrorTypes returnValue = ILM_FAILED;
- struct ilm_control_context *ctx = get_instance();
- lock_context(ctx);
+ struct ilm_control_context *ctx = sync_and_acquire_instance();
struct layer_context *ctx_layer = NULL;
int32_t iviorientation = 0;
returnValue = ILM_SUCCESS;
} while(0);
- unlock_context(ctx);
+ release_instance();
return returnValue;
}
wayland_layerGetOrientation(t_ilm_layer layerId, ilmOrientation *pOrientation)
{
ilmErrorTypes returnValue = ILM_FAILED;
- struct ilm_control_context *ctx = get_instance();
- lock_context(ctx);
+ struct ilm_control_context *ctx = sync_and_acquire_instance();
struct layer_context *ctx_layer = NULL;
if (pOrientation != NULL) {
}
}
- unlock_context(ctx);
+ release_instance();
return returnValue;
}
t_ilm_int number)
{
ilmErrorTypes returnValue = ILM_FAILED;
- struct ilm_control_context *ctx = get_instance();
- lock_context(ctx);
+ struct ilm_control_context *ctx = sync_and_acquire_instance();
struct layer_context *ctx_layer = NULL;
ctx_layer = (struct layer_context*)wayland_controller_get_layer_context(
returnValue = ILM_SUCCESS;
}
- unlock_context(ctx);
+ release_instance();
return returnValue;
}
wayland_surfaceSetVisibility(t_ilm_surface surfaceId, t_ilm_bool newVisibility)
{
ilmErrorTypes returnValue = ILM_FAILED;
- struct ilm_control_context *ctx = get_instance();
- lock_context(ctx);
+ struct ilm_control_context *ctx = sync_and_acquire_instance();
struct surface_context *ctx_surf = NULL;
uint32_t visibility = 0;
returnValue = ILM_SUCCESS;
}
- unlock_context(ctx);
+ release_instance();
return returnValue;
}
wayland_surfaceSetOpacity(t_ilm_surface surfaceId, t_ilm_float opacity)
{
ilmErrorTypes returnValue = ILM_FAILED;
- struct ilm_control_context *ctx = get_instance();
- lock_context(ctx);
+ struct ilm_control_context *ctx = sync_and_acquire_instance();
struct surface_context *ctx_surf = NULL;
wl_fixed_t opacity_fixed = 0;
returnValue = ILM_SUCCESS;
}
- unlock_context(ctx);
+ release_instance();
return returnValue;
}
wayland_surfaceGetOpacity(t_ilm_surface surfaceId, t_ilm_float *pOpacity)
{
ilmErrorTypes returnValue = ILM_FAILED;
- struct ilm_control_context *ctx = get_instance();
- lock_context(ctx);
+ struct ilm_control_context *ctx = sync_and_acquire_instance();
if (pOpacity != NULL) {
struct surface_context *ctx_surf = NULL;
}
}
- unlock_context(ctx);
+ release_instance();
return returnValue;
}
t_ilm_int width, t_ilm_int height)
{
ilmErrorTypes returnValue = ILM_FAILED;
- struct ilm_control_context *ctx = get_instance();
- lock_context(ctx);
+ struct ilm_control_context *ctx = sync_and_acquire_instance();
struct surface_context *ctx_surf = NULL;
ctx_surf = get_surface_context(&ctx->main_ctx, surfaceId);
returnValue = ILM_SUCCESS;
}
- unlock_context(ctx);
+ release_instance();
return returnValue;
}
wayland_surfaceSetDimension(t_ilm_surface surfaceId, t_ilm_uint *pDimension)
{
ilmErrorTypes returnValue = ILM_FAILED;
- struct ilm_control_context *ctx = get_instance();
- lock_context(ctx);
+ struct ilm_control_context *ctx = sync_and_acquire_instance();
if (pDimension != NULL) {
struct surface_context *ctx_surf = NULL;
}
}
- unlock_context(ctx);
+ release_instance();
return returnValue;
}
wayland_surfaceGetPosition(t_ilm_surface surfaceId, t_ilm_uint *pPosition)
{
ilmErrorTypes returnValue = ILM_FAILED;
- struct ilm_control_context *ctx = get_instance();
- lock_context(ctx);
+ struct ilm_control_context *ctx = sync_and_acquire_instance();
if (pPosition != NULL) {
struct surface_context *ctx_surf = NULL;
}
}
- unlock_context(ctx);
+ release_instance();
return returnValue;
}
wayland_surfaceSetPosition(t_ilm_surface surfaceId, t_ilm_uint *pPosition)
{
ilmErrorTypes returnValue = ILM_FAILED;
- struct ilm_control_context *ctx = get_instance();
- lock_context(ctx);
+ struct ilm_control_context *ctx = sync_and_acquire_instance();
if (pPosition != NULL) {
struct surface_context *ctx_surf = NULL;
}
}
- unlock_context(ctx);
+ release_instance();
return returnValue;
}
ilmOrientation orientation)
{
ilmErrorTypes returnValue = ILM_FAILED;
- struct ilm_control_context *ctx = get_instance();
- lock_context(ctx);
+ struct ilm_control_context *ctx = sync_and_acquire_instance();
struct surface_context *ctx_surf = NULL;
int32_t iviorientation = 0;
returnValue = ILM_SUCCESS;
} while(0);
- unlock_context(ctx);
+ release_instance();
return returnValue;
}
ilmOrientation *pOrientation)
{
ilmErrorTypes returnValue = ILM_FAILED;
- struct ilm_control_context *ctx = get_instance();
- lock_context(ctx);
+ struct ilm_control_context *ctx = sync_and_acquire_instance();
if (pOrientation != NULL) {
struct surface_context *ctx_surf = NULL;
}
}
- unlock_context(ctx);
+ release_instance();
return returnValue;
}
ilmPixelFormat *pPixelformat)
{
ilmErrorTypes returnValue = ILM_FAILED;
- struct ilm_control_context *ctx = get_instance();
- lock_context(ctx);
+ struct ilm_control_context *ctx = sync_and_acquire_instance();
if (pPixelformat != NULL) {
struct surface_context *ctx_surf = NULL;
}
}
- unlock_context(ctx);
+ release_instance();
return returnValue;
}
t_ilm_layer *pLayerId, const t_ilm_uint number)
{
ilmErrorTypes returnValue = ILM_FAILED;
- struct ilm_control_context *ctx = get_instance();
- lock_context(ctx);
+ struct ilm_control_context *ctx = sync_and_acquire_instance();
struct screen_context *ctx_scrn = NULL;
ctx_scrn = get_screen_context_by_id(&ctx->main_ctx, (uint32_t)display);
returnValue = ILM_SUCCESS;
}
- unlock_context(ctx);
+ release_instance();
return returnValue;
}
wayland_takeScreenshot(t_ilm_uint screen, t_ilm_const_string filename)
{
ilmErrorTypes returnValue = ILM_FAILED;
- struct ilm_control_context *ctx = get_instance();
- lock_context(ctx);
+ struct ilm_control_context *ctx = sync_and_acquire_instance();
struct screen_context *ctx_scrn = NULL;
ctx_scrn = get_screen_context_by_id(&ctx->main_ctx, (uint32_t)screen);
returnValue = ILM_SUCCESS;
}
- unlock_context(ctx);
+ release_instance();
return returnValue;
}
wayland_takeLayerScreenshot(t_ilm_const_string filename, t_ilm_layer layerid)
{
ilmErrorTypes returnValue = ILM_FAILED;
- struct ilm_control_context *ctx = get_instance();
- lock_context(ctx);
+ struct ilm_control_context *ctx = sync_and_acquire_instance();
struct layer_context *ctx_layer = NULL;
ctx_layer = (struct layer_context*)wayland_controller_get_layer_context(
returnValue = ILM_SUCCESS;
}
- unlock_context(ctx);
+ release_instance();
return returnValue;
}
t_ilm_surface surfaceid)
{
ilmErrorTypes returnValue = ILM_FAILED;
- struct ilm_control_context *ctx = get_instance();
- lock_context(ctx);
+ struct ilm_control_context *ctx = sync_and_acquire_instance();
struct surface_context *ctx_surf = NULL;
ctx_surf = get_surface_context(&ctx->main_ctx, (uint32_t)surfaceid);
returnValue = ILM_SUCCESS;
}
- unlock_context(ctx);
+ release_instance();
return returnValue;
}
layerNotificationFunc callback)
{
ilmErrorTypes returnValue = ILM_FAILED;
- struct ilm_control_context *ctx = get_instance();
- lock_context(ctx);
+ struct ilm_control_context *ctx = sync_and_acquire_instance();
struct layer_context *ctx_layer = NULL;
ctx_layer = (struct layer_context*)wayland_controller_get_layer_context(
returnValue = ILM_SUCCESS;
}
- unlock_context(ctx);
+ release_instance();
return returnValue;
}
surfaceNotificationFunc callback)
{
ilmErrorTypes returnValue = ILM_FAILED;
- struct ilm_control_context *ctx = get_instance();
- lock_context(ctx);
+ struct ilm_control_context *ctx = sync_and_acquire_instance();
struct surface_context *ctx_surf = NULL;
ctx_surf = (struct surface_context*)get_surface_context(
returnValue = ILM_SUCCESS;
}
- unlock_context(ctx);
+ release_instance();
return returnValue;
}
wayland_getNativeHandle(t_ilm_uint pid, t_ilm_int *n_handle,
t_ilm_nativehandle **p_handles)
{
- struct ilm_control_context *ctx = get_instance();
- lock_context(ctx);
+ struct ilm_control_context *ctx = sync_and_acquire_instance();
struct nativehandle_context *p_nh_ctx = NULL;
*n_handle = 0;
}
}
- unlock_context(ctx);
+ release_instance();
return (*n_handle > 0) ? ILM_SUCCESS : ILM_FAILED;
}
struct ilmSurfaceProperties* pSurfaceProperties)
{
ilmErrorTypes returnValue = ILM_FAILED;
- struct ilm_control_context *ctx = get_instance();
- lock_context(ctx);
+ struct ilm_control_context *ctx = sync_and_acquire_instance();
if (pSurfaceProperties != NULL) {
struct surface_context *ctx_surf = NULL;
}
}
- unlock_context(ctx);
+ release_instance();
return returnValue;
}
t_ilm_surface surfaceId)
{
ilmErrorTypes returnValue = ILM_FAILED;
- struct ilm_control_context *ctx = get_instance();
- lock_context(ctx);
+ struct ilm_control_context *ctx = sync_and_acquire_instance();
struct layer_context *ctx_layer = NULL;
struct surface_context *ctx_surf = NULL;
returnValue = ILM_SUCCESS;
}
- unlock_context(ctx);
+ release_instance();
return returnValue;
}
t_ilm_surface surfaceId)
{
ilmErrorTypes returnValue = ILM_FAILED;
- struct ilm_control_context *ctx = get_instance();
- lock_context(ctx);
+ struct ilm_control_context *ctx = sync_and_acquire_instance();
struct layer_context *ctx_layer = NULL;
struct surface_context *ctx_surf = NULL;
returnValue = ILM_SUCCESS;
}
- unlock_context(ctx);
+ release_instance();
return returnValue;
}
t_ilm_uint *pDimension)
{
ilmErrorTypes returnValue = ILM_FAILED;
- struct ilm_control_context *ctx = get_instance();
- lock_context(ctx);
+ struct ilm_control_context *ctx = sync_and_acquire_instance();
if (pDimension != NULL) {
struct surface_context *ctx_surf = NULL;
}
}
- unlock_context(ctx);
+ release_instance();
return returnValue;
}
t_ilm_bool *pVisibility)
{
ilmErrorTypes returnValue = ILM_FAILED;
- struct ilm_control_context *ctx = get_instance();
- lock_context(ctx);
+ struct ilm_control_context *ctx = sync_and_acquire_instance();
struct surface_context *ctx_surf = NULL;
if (pVisibility != NULL) {
}
}
- unlock_context(ctx);
+ release_instance();
return returnValue;
}
t_ilm_int width, t_ilm_int height)
{
ilmErrorTypes returnValue = ILM_FAILED;
- struct ilm_control_context *ctx = get_instance();
- lock_context(ctx);
+ struct ilm_control_context *ctx = sync_and_acquire_instance();
struct surface_context *ctx_surf = NULL;
ctx_surf = get_surface_context(&ctx->main_ctx, (uint32_t)surfaceId);
}
}
- unlock_context(ctx);
+ release_instance();
return returnValue;
}
wayland_commitChanges(void)
{
ilmErrorTypes returnValue = ILM_FAILED;
- struct ilm_control_context *ctx = get_instance();
- lock_context(ctx);
+ struct ilm_control_context *ctx = sync_and_acquire_instance();
if (ctx->main_ctx.controller != NULL) {
ivi_controller_commit_changes(ctx->main_ctx.controller);
returnValue = ILM_SUCCESS;
}
- unlock_context(ctx);
+ release_instance();
+
return returnValue;
}