/**************************************************************************
-
-libtdm
-
-Copyright 2015 Samsung Electronics co., Ltd. All Rights Reserved.
-
-Contact: Eunchul Kim <chulspro.kim@samsung.com>,
- JinYoung Jeon <jy0.jeon@samsung.com>,
- Taeheon Kim <th908.kim@samsung.com>,
- YoungJun Cho <yj44.cho@samsung.com>,
- SooChan Lim <sc1.lim@samsung.com>,
- Boram Park <sc1.lim@samsung.com>
-
-Permission is hereby granted, free of charge, to any person obtaining a
-copy of this software and associated documentation files (the
-"Software"), to deal in the Software without restriction, including
-without limitation the rights to use, copy, modify, merge, publish,
-distribute, sub license, and/or sell copies of the Software, and to
-permit persons to whom the Software is furnished to do so, subject to
-the following conditions:
-
-The above copyright notice and this permission notice (including the
-next paragraph) shall be included in all copies or substantial portions
-of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
-OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
-IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
-ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
-TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
-SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
+ *
+ * libtdm
+ *
+ * Copyright 2015 Samsung Electronics co., Ltd. All Rights Reserved.
+ *
+ * Contact: Eunchul Kim <chulspro.kim@samsung.com>,
+ * JinYoung Jeon <jy0.jeon@samsung.com>,
+ * Taeheon Kim <th908.kim@samsung.com>,
+ * YoungJun Cho <yj44.cho@samsung.com>,
+ * SooChan Lim <sc1.lim@samsung.com>,
+ * Boram Park <sc1.lim@samsung.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
**************************************************************************/
#ifdef HAVE_CONFIG_H
#include <wayland-server-core.h>
-typedef struct _tdm_event_loop_source_base
-{
+typedef struct _tdm_event_loop_source_base {
struct wl_event_source *wl_source;
} tdm_event_loop_source_base;
-typedef struct _tdm_event_loop_source_fd
-{
+typedef struct _tdm_event_loop_source_fd {
tdm_event_loop_source_base base;
tdm_private_display *private_display;
tdm_event_loop_fd_handler func;
void *user_data;
} tdm_event_loop_source_fd;
-typedef struct _tdm_event_loop_source_timer
-{
+typedef struct _tdm_event_loop_source_timer {
tdm_event_loop_source_base base;
tdm_private_display *private_display;
tdm_event_loop_timer_handler func;
private_loop = private_display->private_loop;
- if (tdm_debug_thread)
+ if (tdm_debug_module & TDM_DEBUG_THREAD)
TDM_INFO("backend fd(%d) event happens", private_loop->backend_fd);
func_display = &private_display->func_display;
if (private_display->private_loop)
return TDM_ERROR_NONE;
- private_loop = calloc(1, sizeof *private_loop);
+ private_loop = calloc(1, sizeof * private_loop);
if (!private_loop) {
TDM_ERR("alloc failed");
return TDM_ERROR_OUT_OF_MEMORY;
if (!private_display->private_loop)
return;
+ /* after tdm_thread_deinit, we don't worry about thread things because it's finalized */
tdm_thread_deinit(private_display->private_loop);
tdm_server_deinit(private_display->private_loop);
private_loop->backend_source =
tdm_event_loop_add_fd_handler(private_display, fd,
- TDM_EVENT_LOOP_READABLE,
- _tdm_event_loop_main_fd_handler,
- private_display, &ret);
+ TDM_EVENT_LOOP_READABLE,
+ _tdm_event_loop_main_fd_handler,
+ private_display, &ret);
if (!private_loop->backend_source) {
TDM_ERR("no backend fd(%d) source", fd);
return;
TDM_RETURN_VAL_IF_FAIL(private_loop->wl_loop != NULL, TDM_ERROR_OPERATION_FAILED);
- if (tdm_debug_thread)
+ if (tdm_debug_module & TDM_DEBUG_THREAD)
TDM_INFO("dispatch");
if (tdm_thread_is_running() &&
- tdm_thread_in_display_thread(syscall(SYS_gettid))) {
+ tdm_thread_in_display_thread(syscall(SYS_gettid))) {
TDM_NEVER_GET_HERE();
return TDM_ERROR_OPERATION_FAILED;
}
TDM_RETURN_IF_FAIL(private_loop->wl_display != NULL);
if (tdm_thread_is_running() &&
- tdm_thread_in_display_thread(syscall(SYS_gettid))) {
+ tdm_thread_in_display_thread(syscall(SYS_gettid))) {
TDM_NEVER_GET_HERE();
return;
}
return 1;
}
-EXTERN tdm_event_loop_source*
+EXTERN tdm_event_loop_source *
tdm_event_loop_add_fd_handler(tdm_display *dpy, int fd, tdm_event_loop_mask mask,
- tdm_event_loop_fd_handler func, void *user_data,
- tdm_error *error)
+ tdm_event_loop_fd_handler func, void *user_data,
+ tdm_error *error)
{
tdm_private_display *private_display;
tdm_private_loop *private_loop;
fd_source->base.wl_source =
wl_event_loop_add_fd(private_loop->wl_loop,
- fd, wl_mask, _tdm_event_loop_fd_func, fd_source);
+ fd, wl_mask, _tdm_event_loop_fd_func, fd_source);
if (!fd_source->base.wl_source) {
if (error)
*error = TDM_ERROR_OUT_OF_MEMORY;
if (error)
*error = TDM_ERROR_NONE;
- return (tdm_event_loop_source*)fd_source;
+ return (tdm_event_loop_source *)fd_source;
}
EXTERN tdm_error
private_display = timer_source->private_display;
+ /* TDM event_loop function is actually for TDM backend module. When we call the
+ * backend's functions, we have to lock the mutex. TDM backend shouldn't consider
+ * mutex things.
+ */
_pthread_mutex_lock(&private_display->lock);
timer_source->func(timer_source->user_data);
_pthread_mutex_unlock(&private_display->lock);
return 1;
}
-EXTERN tdm_event_loop_source*
+EXTERN tdm_event_loop_source *
tdm_event_loop_add_timer_handler(tdm_display *dpy, tdm_event_loop_timer_handler func,
- void *user_data, tdm_error *error)
+ void *user_data, tdm_error *error)
{
tdm_private_display *private_display;
tdm_private_loop *private_loop;
timer_source->base.wl_source =
wl_event_loop_add_timer(private_loop->wl_loop,
- _tdm_event_loop_timer_func, timer_source);
+ _tdm_event_loop_timer_func, timer_source);
if (!timer_source->base.wl_source) {
if (error)
*error = TDM_ERROR_OUT_OF_MEMORY;
if (error)
*error = TDM_ERROR_NONE;
- return (tdm_event_loop_source*)timer_source;
+ return (tdm_event_loop_source *)timer_source;
}
EXTERN tdm_error