summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcus Fritzsch <marcus.fritzsch@xse.de>2014-08-05 13:36:38 +0200
committerNobuhiko Tanibata <NOBUHIKO_TANIBATA@denso.co.jp>2014-09-01 15:55:43 +0900
commitcdd3c72ddea380ef1ca6518b8ac1346e8040c8ac (patch)
tree23f1b647d9ffd87ad119de7ffc73814ef4b8b770
parentb42f02b255ec8a1b3efeca926450b5e21d9e8c72 (diff)
downloadwayland-ivi-extension-cdd3c72ddea380ef1ca6518b8ac1346e8040c8ac.tar.gz
ilmControl: rewrite sync_and_acquire_instance
* Moved all of the code to impl_sync_and_acquire_instance * The macro still allows for ILM_FAILED return if instance is not correctly initialized or the wayland display connection broke. Signed-off-by: Marcus Fritzsch <marcus.fritzsch@xse.de>
-rw-r--r--ivi-layermanagement-api/ilmControl/src/ilm_control_wayland_platform.c34
1 files changed, 27 insertions, 7 deletions
diff --git a/ivi-layermanagement-api/ilmControl/src/ilm_control_wayland_platform.c b/ivi-layermanagement-api/ilmControl/src/ilm_control_wayland_platform.c
index faf8b99..6016e1a 100644
--- a/ivi-layermanagement-api/ilmControl/src/ilm_control_wayland_platform.c
+++ b/ivi-layermanagement-api/ilmControl/src/ilm_control_wayland_platform.c
@@ -168,7 +168,8 @@ static inline void unlock_context(struct ilm_control_context *ctx)
static int init_control(void);
-static struct ilm_control_context* sync_and_acquire_instance(void);
+static ilmErrorTypes impl_sync_and_acquire_instance(struct ilm_control_context *ctx);
+
static struct surface_context* get_surface_context(struct wayland_context *, uint32_t);
static void release_instance(void);
@@ -1195,7 +1196,7 @@ init_control(void)
if (! wl->controller)
{
- fputs("ivi_controller not available\n", stderr);
+ fprintf(stderr, "ivi_controller not available\n");
return -1;
}
@@ -1219,14 +1220,33 @@ init_control(void)
return 0;
}
+static ilmErrorTypes impl_sync_and_acquire_instance(struct ilm_control_context *ctx)
+{
+ if (! ctx->initialized) {
+ fprintf(stderr, "Not initialized\n");
+ return ILM_FAILED;
+ }
+
+ lock_context(ctx);
+
+ if (display_roundtrip_queue(ctx->wl.display, ctx->wl.queue) == -1) {
+ int err = wl_display_get_error(ctx->wl.display);
+ fprintf(stderr, "Error communicating with wayland: %s\n", strerror(err));
+ unlock_context(ctx);
+ return ILM_FAILED;
+ }
+
+ return ILM_SUCCESS;
+}
+
#define sync_and_acquire_instance() ({ \
struct ilm_control_context *ctx = &ilm_context; \
- if (! ctx->initialized) { \
- fputs("Not initialized\n", stderr); \
- return ILM_FAILED; \
+ { \
+ ilmErrorTypes status = impl_sync_and_acquire_instance(ctx); \
+ if (status != ILM_SUCCESS) { \
+ return status; \
+ } \
} \
- lock_context(ctx); \
- display_roundtrip_queue(ctx->wl.display, ctx->wl.queue); \
ctx; \
})