static tpl_wl_egl_buffer_t *
_get_wl_egl_buffer(tbm_surface_h tbm_surface);
static int
-_write_to_eventfd(int eventfd);
+_write_to_eventfd(int eventfd, uint64_t value);
+static int
+send_signal(int fd, const char *type);
static void
_thread_wl_egl_surface_init(tpl_wl_egl_surface_t *wl_egl_surface);
static tpl_result_t
(struct pst_feedback *)__tpl_list_pop_front(
wl_egl_surface->presentation_feedbacks, NULL);
if (pst_feedback) {
- _write_to_eventfd(pst_feedback->pst_sync_fd);
- close(pst_feedback->pst_sync_fd);
+ send_signal(pst_feedback->pst_sync_fd, "PST_FEEDBACK");
pst_feedback->pst_sync_fd = -1;
wp_presentation_feedback_destroy(pst_feedback->presentation_feedback);
wl_egl_surface->presentation_feedbacks = NULL;
}
- if (wl_egl_surface->presentation_sync.fd != -1) {
- _write_to_eventfd(wl_egl_surface->presentation_sync.fd);
- close(wl_egl_surface->presentation_sync.fd);
- wl_egl_surface->presentation_sync.fd = -1;
- }
+ send_signal(wl_egl_surface->presentation_sync.fd, "PST_SYNC");
+ wl_egl_surface->presentation_sync.fd = -1;
tpl_gmutex_unlock(&wl_egl_surface->presentation_sync.mutex);
pst_feedback, presentation_feedback, pst_feedback->bo_name);
if (pst_feedback->pst_sync_fd != -1) {
- int ret = _write_to_eventfd(pst_feedback->pst_sync_fd);
- if (ret == -1) {
- TPL_ERR("Failed to send presentation_sync signal to fd(%d)",
- pst_feedback->pst_sync_fd);
- }
-
TRACE_ASYNC_END(pst_feedback->pst_sync_fd,
"[PRESENTATION_SYNC] bo(%d)",
pst_feedback->bo_name);
-
- close(pst_feedback->pst_sync_fd);
+ send_signal(pst_feedback->pst_sync_fd, "PST_FEEDBACK");
pst_feedback->pst_sync_fd = -1;
}
pst_feedback, presentation_feedback, pst_feedback->bo_name);
if (pst_feedback->pst_sync_fd != -1) {
- int ret = _write_to_eventfd(pst_feedback->pst_sync_fd);
- if (ret == -1) {
- TPL_ERR("Failed to send presentation_sync signal to fd(%d)",
- pst_feedback->pst_sync_fd);
- }
-
TRACE_ASYNC_END(pst_feedback->pst_sync_fd,
"[PRESENTATION_SYNC] bo(%d)",
pst_feedback->bo_name);
-
- close(pst_feedback->pst_sync_fd);
+ send_signal(pst_feedback->pst_sync_fd, "PST_FEEDBACK");
pst_feedback->pst_sync_fd = -1;
}
} else {
TPL_ERR("Failed to create presentation feedback. wl_egl_buffer(%p)",
wl_egl_buffer);
- _write_to_eventfd(wl_egl_buffer->presentation_sync_fd);
- close(wl_egl_buffer->presentation_sync_fd);
+ send_signal(wl_egl_buffer->presentation_sync_fd, "PST_SYNC");
wl_egl_buffer->presentation_sync_fd = -1;
}
}
tpl_gmutex_lock(&wl_egl_surface->commit_sync.mutex);
if (wl_egl_buffer->commit_sync_fd != -1) {
- int ret = _write_to_eventfd(wl_egl_buffer->commit_sync_fd);
- if (ret == -1) {
- TPL_ERR("Failed to send commit_sync signal to fd(%d)", wl_egl_buffer->commit_sync_fd);
- }
-
TRACE_ASYNC_END(wl_egl_buffer->commit_sync_fd, "[COMMIT_SYNC] bo(%d)",
wl_egl_buffer->bo_name);
TPL_LOG_D("[COMMIT_SYNC][SEND]", "wl_egl_surface(%p) commit_sync_fd(%d)",
wl_egl_surface, wl_egl_buffer->commit_sync_fd);
-
- close(wl_egl_buffer->commit_sync_fd);
+ send_signal(wl_egl_buffer->commit_sync_fd, "COMMIT_SYNC");
wl_egl_buffer->commit_sync_fd = -1;
}
}
static int
-_write_to_eventfd(int eventfd)
+_write_to_eventfd(int eventfd, uint64_t value)
{
- uint64_t value = 1;
int ret;
- if (eventfd == -1) {
- TPL_ERR("Invalid fd(-1)");
- return -1;
- }
-
ret = write(eventfd, &value, sizeof(uint64_t));
if (ret == -1) {
TPL_ERR("failed to write to fd(%d)", eventfd);
return ret;
}
+static int send_signal(int fd, const char *type)
+{
+ int ret = 0;
+ if (fd < 0) return ret;
+
+ ret = _write_to_eventfd(fd, 1);
+ if (ret < 0)
+ TPL_ERR("Failed to send %s signal to fd(%d)", type, fd);
+
+ close(fd);
+
+ return ret;
+}
+
void
__tpl_display_init_backend_wl_egl_thread(tpl_display_backend_t *backend)
{
wl_egl_buffer->waiting_source = NULL;
}
- if (wl_egl_buffer->commit_sync_fd != -1) {
- int ret = _write_to_eventfd(wl_egl_buffer->commit_sync_fd);
- if (ret == -1)
- TPL_ERR("Failed to send commit_sync signal to fd(%d)",
- wl_egl_buffer->commit_sync_fd);
- close(wl_egl_buffer->commit_sync_fd);
- wl_egl_buffer->commit_sync_fd = -1;
- }
+ send_signal(wl_egl_buffer->commit_sync_fd, "COMMIT_SYNC");
+ wl_egl_buffer->commit_sync_fd = -1;
- if (wl_egl_buffer->presentation_sync_fd != -1) {
- int ret = _write_to_eventfd(wl_egl_buffer->presentation_sync_fd);
- if (ret == -1)
- TPL_ERR("Failed to send presentation_sync signal to fd(%d)",
- wl_egl_buffer->presentation_sync_fd);
- close(wl_egl_buffer->presentation_sync_fd);
- wl_egl_buffer->presentation_sync_fd = -1;
- }
+ send_signal(wl_egl_buffer->presentation_sync_fd, "PST_SYNC");
+ wl_egl_buffer->presentation_sync_fd = -1;
if (wl_egl_buffer->rects) {
free(wl_egl_buffer->rects);