diff options
author | Marcus Fritzsch <marcus.fritzsch@xse.de> | 2014-07-29 15:37:08 +0200 |
---|---|---|
committer | Nobuhiko Tanibata <NOBUHIKO_TANIBATA@denso.co.jp> | 2014-08-12 22:15:14 +0900 |
commit | d951b3804595e537adfbbfb276544125a7ca4394 (patch) | |
tree | cc6e5ba858f65d3c099f3132b49d800fabc6b224 | |
parent | 5c2db2686b1fea10579de402b93b2fa5492a44ee (diff) | |
download | wayland-ivi-extension-d951b3804595e537adfbbfb276544125a7ca4394.tar.gz |
ilmControl: get rid of context::valid
Replace valid with a needed "initialized" flag, also don't use
this flag to determine thread termination, pthread_cancel() is
used.
Signed-off-by: Marcus Fritzsch <marcus.fritzsch@xse.de>
-rw-r--r-- | ivi-layermanagement-api/ilmControl/src/ilm_control_wayland_platform.c | 31 |
1 files changed, 12 insertions, 19 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 22b6563..796878c 100644 --- a/ivi-layermanagement-api/ilmControl/src/ilm_control_wayland_platform.c +++ b/ivi-layermanagement-api/ilmControl/src/ilm_control_wayland_platform.c @@ -19,10 +19,13 @@ #include <stdlib.h> #include <string.h> #include <memory.h> -#include <unistd.h> #include <pthread.h> #include <signal.h> +#include <stdbool.h> + +#include <unistd.h> #include <poll.h> + #include "ilm_common.h" #include "ilm_control_platform.h" #include "wayland-util.h" @@ -346,7 +349,7 @@ struct wayland_context { struct ilm_control_context { struct wayland_context wl; - int32_t valid; + bool initialized; uint32_t num_screen; @@ -403,6 +406,8 @@ static int init_control(void); static struct ilm_control_context* sync_and_acquire_instance(void); +static void release_instance(void); + static int create_controller_layer(struct wayland_context *ctx, t_ilm_uint width, t_ilm_uint height, t_ilm_layer layerid); static int32_t @@ -1207,15 +1212,12 @@ static void wayland_destroy(void) { struct ilm_control_context *ctx = &ilm_context; - lock_context(ctx); - ctx->valid = 0; - unlock_context(ctx); - void* threadRetVal = NULL; pthread_cancel(ctx->thread); - if (0 != pthread_join(ctx->thread, &threadRetVal)) { + if (0 != pthread_join(ctx->thread, NULL)) { fprintf(stderr, "failed to join control thread\n"); } destroy_control_resources(); + memset(ctx, 0, sizeof *ctx); } static ilmErrorTypes @@ -1223,7 +1225,7 @@ wayland_init(t_ilm_nativedisplay nativedisplay) { struct ilm_control_context *ctx = &ilm_context; - if (ctx->valid != 0) + if (ctx->initialized) { fprintf(stderr, "Already initialized!\n"); return ILM_FAILED; @@ -1288,15 +1290,6 @@ control_thread(void *p_ret) while (1) { - lock_context(ctx); - int valid = ctx->valid; - unlock_context(ctx); - - if (valid != 1) - { - break; - } - if (wl_display_prepare_read_queue(display, queue) != 0) { lock_context(ctx); @@ -1374,8 +1367,6 @@ init_control(void) display_roundtrip_queue(wl->display, wl->queue); display_roundtrip_queue(wl->display, wl->queue); - ctx->valid = 1; - ret = pthread_create(&ctx->thread, NULL, control_thread, NULL); if (ret != 0) { @@ -1383,6 +1374,8 @@ init_control(void) return -1; } + ctx->initialized = true; + return 0; } |