struct list_head call_link;
} tdm_client_wait_info;
+static unsigned int
+_tdm_client_check_wl_error(tdm_private_client *private_client, const char *func, int line)
+{
+ uint32_t ec, id;
+ const struct wl_interface *intf;
+ int err;
+
+ err = wl_display_get_error(private_client->display);
+ if (!err)
+ return false;
+
+ if (err == EINVAL || err == ENOMEM || err == EFAULT || err == EPROTO) {
+ ec = wl_display_get_protocol_error(private_client->display, &intf, &id);
+ TDM_ERR("[%s,%d] errno(%d) Got protocol error '%u' on interface '%s' (object '%u')",
+ func, line, err, ec, (intf) ? intf->name : "destroyed", id);
+ } else {
+ TDM_ERR("[%s,%d] errno(%d)", func, line, err);
+ }
+
+ return true;
+}
+
+#define CHECK_WL_PROTOCOL_ERROR(pc) _tdm_client_check_wl_error(pc, __FUNCTION__, __LINE__)
+
static void
_tdm_client_vblank_cb_stamp(void *data, struct wl_tdm_vblank *wl_tdm_vblank, uint32_t stamp)
{
&tdm_client_registry_listener, private_client);
wl_display_roundtrip(private_client->display);
+ if (CHECK_WL_PROTOCOL_ERROR(private_client))
+ goto create_failed;
+
/* check global objects */
TDM_GOTO_IF_FAIL(private_client->tdm != NULL, create_failed);
pthread_mutex_lock(&private_client->lock);
+ if (CHECK_WL_PROTOCOL_ERROR(private_client)) {
+ pthread_mutex_unlock(&private_client->lock);
+ return TDM_ERROR_PROTOCOL_ERROR;
+ }
+
if (private_client->enable_ttrace)
TDM_TRACE_ASYNC_BEGIN((int)private_client->stamp, "TDM_Client_Events:%u", (unsigned int)private_client->stamp);
if (private_client->enable_ttrace)
TDM_TRACE_ASYNC_END((int)private_client->stamp, "TDM_Client_Events:%u", (unsigned int)private_client->stamp);
+ if (CHECK_WL_PROTOCOL_ERROR(private_client)) {
+ pthread_mutex_unlock(&private_client->lock);
+ return TDM_ERROR_PROTOCOL_ERROR;
+ }
+
pthread_mutex_unlock(&private_client->lock);
return TDM_ERROR_NONE;
TDM_RETURN_VAL_IF_FAIL(interval > 0, TDM_ERROR_INVALID_PARAMETER);
TDM_RETURN_VAL_IF_FAIL(func != NULL, TDM_ERROR_INVALID_PARAMETER);
+ if (CHECK_WL_PROTOCOL_ERROR(private_client))
+ return TDM_ERROR_PROTOCOL_ERROR;
+
if (!private_client->temp_vblank) {
output = tdm_client_get_output(client, name, &ret);
TDM_RETURN_VAL_IF_FAIL(output != NULL, ret);
pthread_mutex_lock(&private_client->lock);
+ if (CHECK_WL_PROTOCOL_ERROR(private_client)) {
+ if (error)
+ *error = TDM_ERROR_PROTOCOL_ERROR;
+ pthread_mutex_unlock(&private_client->lock);
+ return NULL;
+ }
+
if (!name)
name = "primary";
LIST_INITHEAD(&private_output->vblank_list);
LIST_INITHEAD(&private_output->change_handler_list);
- LIST_ADDTAIL(&private_output->link, &private_client->output_list);
wl_tdm_output_add_listener(private_output->output,
&tdm_client_output_listener, private_output);
wl_proxy_set_queue((struct wl_proxy *)private_output->output, NULL);
+ if (CHECK_WL_PROTOCOL_ERROR(private_client)) {
+ wl_tdm_output_destroy(private_output->output);
+ free(private_output);
+ if (error)
+ *error = TDM_ERROR_PROTOCOL_ERROR;
+ pthread_mutex_unlock(&private_client->lock);
+ return NULL;
+ }
+
+ LIST_ADDTAIL(&private_output->link, &private_client->output_list);
+
pthread_mutex_unlock(&private_client->lock);
return (tdm_client_output*)private_output;
pthread_mutex_lock(&private_client->lock);
+ if (CHECK_WL_PROTOCOL_ERROR(private_client)) {
+ free(h);
+ pthread_mutex_unlock(&private_client->lock);
+ return TDM_ERROR_PROTOCOL_ERROR;
+ }
+
if (LIST_IS_EMPTY(&private_output->change_handler_list)) {
wl_tdm_output_watch_output_changes(private_output->output, 1);
LIST_DEL(&h->link);
free(h);
- if (LIST_IS_EMPTY(&private_output->change_handler_list))
- wl_tdm_output_watch_output_changes(private_output->output, 0);
+ if (LIST_IS_EMPTY(&private_output->change_handler_list)) {
+ if (!CHECK_WL_PROTOCOL_ERROR(private_client))
+ wl_tdm_output_watch_output_changes(private_output->output, 0);
+ }
pthread_mutex_unlock(&private_client->lock);
return TDM_ERROR_NONE;
}
+ if (CHECK_WL_PROTOCOL_ERROR(private_client)) {
+ pthread_mutex_unlock(&private_client->lock);
+ return TDM_ERROR_PROTOCOL_ERROR;
+ }
+
wl_proxy_set_queue((struct wl_proxy *)private_output->output, private_client->queue);
wl_tdm_output_get_mode(private_output->output);
wl_display_roundtrip_queue(private_client->display, private_client->queue);
wl_proxy_set_queue((struct wl_proxy *)private_output->output, NULL);
+ if (CHECK_WL_PROTOCOL_ERROR(private_client)) {
+ pthread_mutex_unlock(&private_client->lock);
+ return TDM_ERROR_PROTOCOL_ERROR;
+ }
+
*refresh = private_output->refresh;
pthread_mutex_unlock(&private_client->lock);
return TDM_ERROR_NONE;
}
+ if (CHECK_WL_PROTOCOL_ERROR(private_client)) {
+ pthread_mutex_unlock(&private_client->lock);
+ return TDM_ERROR_PROTOCOL_ERROR;
+ }
+
wl_proxy_set_queue((struct wl_proxy *)private_output->output, private_client->queue);
wl_tdm_output_get_connection(private_output->output);
wl_display_roundtrip_queue(private_client->display, private_client->queue);
wl_proxy_set_queue((struct wl_proxy *)private_output->output, NULL);
+ if (CHECK_WL_PROTOCOL_ERROR(private_client)) {
+ pthread_mutex_unlock(&private_client->lock);
+ return TDM_ERROR_PROTOCOL_ERROR;
+ }
+
*status = private_output->connection;
pthread_mutex_unlock(&private_client->lock);
pthread_mutex_lock(&private_client->lock);
+ if (CHECK_WL_PROTOCOL_ERROR(private_client)) {
+ pthread_mutex_unlock(&private_client->lock);
+ return TDM_ERROR_PROTOCOL_ERROR;
+ }
+
wl_proxy_set_queue((struct wl_proxy *)private_output->output, private_client->queue);
wl_tdm_output_get_dpms(private_output->output);
wl_display_roundtrip_queue(private_client->display, private_client->queue);
wl_proxy_set_queue((struct wl_proxy *)private_output->output, NULL);
+ if (CHECK_WL_PROTOCOL_ERROR(private_client)) {
+ pthread_mutex_unlock(&private_client->lock);
+ return TDM_ERROR_PROTOCOL_ERROR;
+ }
+
*dpms = private_output->dpms;
pthread_mutex_unlock(&private_client->lock);
pthread_mutex_lock(&private_client->lock);
+ if (CHECK_WL_PROTOCOL_ERROR(private_client)) {
+ if (error)
+ *error = TDM_ERROR_PROTOCOL_ERROR;
+ pthread_mutex_unlock(&private_client->lock);
+ return NULL;
+ }
+
wrapper = wl_proxy_create_wrapper(private_output->output);
if (!wrapper) {
TDM_ERR("create output_wrapper failed");
private_vblank->enable_fake = 0;
LIST_INITHEAD(&private_vblank->wait_list);
- LIST_ADDTAIL(&private_vblank->link, &private_output->vblank_list);
wl_tdm_vblank_add_listener(private_vblank->vblank,
&tdm_client_vblank_listener, private_vblank);
wl_proxy_set_queue((struct wl_proxy *)private_vblank->vblank, NULL);
+ if (CHECK_WL_PROTOCOL_ERROR(private_client)) {
+ wl_tdm_vblank_destroy(private_vblank->vblank);
+ free(private_vblank);
+ if (error)
+ *error = TDM_ERROR_PROTOCOL_ERROR;
+ pthread_mutex_unlock(&private_client->lock);
+ return NULL;
+ }
+
+ LIST_ADDTAIL(&private_vblank->link, &private_output->vblank_list);
+
pthread_mutex_unlock(&private_client->lock);
return (tdm_client_vblank*)private_vblank;
pthread_mutex_lock(&private_client->lock);
+ if (CHECK_WL_PROTOCOL_ERROR(private_client)) {
+ pthread_mutex_unlock(&private_client->lock);
+ return TDM_ERROR_PROTOCOL_ERROR;
+ }
+
if (!name)
name = TDM_VBLANK_DEFAULT_NAME;
pthread_mutex_lock(&private_client->lock);
+ if (CHECK_WL_PROTOCOL_ERROR(private_client)) {
+ pthread_mutex_unlock(&private_client->lock);
+ return TDM_ERROR_PROTOCOL_ERROR;
+ }
+
if (private_vblank->fps == fps) {
pthread_mutex_unlock(&private_client->lock);
return TDM_ERROR_NONE;
pthread_mutex_lock(&private_client->lock);
+ if (CHECK_WL_PROTOCOL_ERROR(private_client)) {
+ pthread_mutex_unlock(&private_client->lock);
+ return TDM_ERROR_PROTOCOL_ERROR;
+ }
+
if (private_vblank->offset == offset_ms) {
pthread_mutex_unlock(&private_client->lock);
return TDM_ERROR_NONE;
pthread_mutex_lock(&private_client->lock);
+ if (CHECK_WL_PROTOCOL_ERROR(private_client)) {
+ pthread_mutex_unlock(&private_client->lock);
+ return TDM_ERROR_PROTOCOL_ERROR;
+ }
+
if (private_vblank->enable_fake == enable_fake) {
pthread_mutex_unlock(&private_client->lock);
return TDM_ERROR_NONE;
pthread_mutex_lock(&private_client->lock);
+ if (CHECK_WL_PROTOCOL_ERROR(private_client)) {
+ pthread_mutex_unlock(&private_client->lock);
+ return TDM_ERROR_PROTOCOL_ERROR;
+ }
+
if (!private_vblank->started)
private_vblank->started = 1;
LIST_DEL(&w->link);
free(w);
+ if (CHECK_WL_PROTOCOL_ERROR(private_client)) {
+ pthread_mutex_unlock(&private_client->lock);
+ return TDM_ERROR_PROTOCOL_ERROR;
+ }
+
pthread_mutex_unlock(&private_client->lock);
return TDM_ERROR_NONE;
pthread_mutex_lock(&private_client->lock);
+ if (CHECK_WL_PROTOCOL_ERROR(private_client)) {
+ pthread_mutex_unlock(&private_client->lock);
+ return TDM_ERROR_PROTOCOL_ERROR;
+ }
+
if (!private_vblank->started)
private_vblank->started = 1;
LIST_DEL(&w->link);
free(w);
+ if (CHECK_WL_PROTOCOL_ERROR(private_client)) {
+ pthread_mutex_unlock(&private_client->lock);
+ return TDM_ERROR_PROTOCOL_ERROR;
+ }
+
pthread_mutex_unlock(&private_client->lock);
return TDM_ERROR_NONE;