typedef struct _tdm_private_client_voutput {
tdm_private_client_output base;
struct wl_tdm_voutput *wl_voutput;
+ struct list_head commit_handler_list;
struct
{
struct list_head call_link;
} tdm_client_wait_info;
+typedef struct _tdm_client_voutput_commit_handler_info
+{
+ tdm_private_client_voutput *private_voutput;
+
+ tdm_client_voutput_commit_handler func;
+ void *user_data;
+
+ struct list_head link;
+ struct list_head call_link;
+} tdm_client_voutput_commit_handler_info;
+
static unsigned int
_tdm_client_check_wl_error(tdm_private_client *private_client, const char *func, int line)
{
}
void
+tdm_client_voutput_cb_commit(void *data, struct wl_tdm_voutput *wl_voutput)
+{
+ tdm_private_client_voutput *private_voutput;
+ tdm_private_client *private_client;
+ tdm_client_voutput_commit_handler_info *h = NULL, *hh = NULL;
+ struct list_head call_list;
+
+ private_voutput = (tdm_private_client_voutput *)data;
+ TDM_RETURN_IF_FAIL(private_voutput != NULL);
+
+ private_client = private_voutput->base.private_client;
+
+ LIST_INITHEAD(&call_list);
+
+ LIST_FOR_EACH_ENTRY(h, &private_voutput->commit_handler_list, link) {
+ LIST_ADDTAIL(&h->call_link, &call_list);
+ }
+
+ pthread_mutex_unlock(&private_client->lock);
+ LIST_FOR_EACH_ENTRY_SAFE(h, hh, &call_list, call_link) {
+ if (h->func)
+ h->func(private_voutput, h->user_data);
+ }
+ pthread_mutex_lock(&private_client->lock);
+}
+
+void
tdm_client_voutput_cb_ack_message(void *data, struct wl_tdm_voutput *wl_voutput, uint32_t msg)
{
tdm_private_client_voutput *private_voutput = data;
}
static const struct wl_tdm_voutput_listener tdm_client_voutput_lisntener = {
+ tdm_client_voutput_cb_commit,
tdm_client_voutput_cb_ack_message
};
/* LOCV_EXCL_STOP */
}
+ LIST_INITHEAD(&private_voutput->commit_handler_list);
+
private_voutput->base.private_client = private_client;
private_voutput->wl_voutput = wl_tdm_create_voutput((struct wl_tdm *)wrapper, private_voutput->base.name);
tdm_client_voutput_destroy(tdm_client_voutput *voutput)
{
tdm_private_client_voutput *private_voutput = (tdm_private_client_voutput *)voutput;
+ tdm_client_voutput_commit_handler_info *h = NULL, *hh = NULL;
if (!private_voutput)
return;
if (private_voutput->available_formats.formats)
free(private_voutput->available_formats.formats);
+ LIST_FOR_EACH_ENTRY_SAFE(h, hh, &private_voutput->commit_handler_list, link) {
+ LIST_DEL(&h->link);
+ free(h);
+ }
+
wl_tdm_voutput_destroy(private_voutput->wl_voutput);
free(private_voutput);
return TDM_ERROR_NONE;
}
+tdm_error
+tdm_client_voutput_add_commit_handler(tdm_client_voutput *voutput,
+ tdm_client_voutput_commit_handler func,
+ void *user_data)
+{
+ tdm_private_client_voutput *private_voutput;
+ tdm_private_client *private_client;
+ tdm_client_voutput_commit_handler_info *h = NULL;
+
+ TDM_RETURN_VAL_IF_FAIL(voutput != NULL, TDM_ERROR_INVALID_PARAMETER);
+ TDM_RETURN_VAL_IF_FAIL(func != NULL, TDM_ERROR_INVALID_PARAMETER);
+
+ private_voutput = (tdm_private_client_voutput *)voutput;
+ private_client = private_voutput->base.private_client;
+
+ LIST_FOR_EACH_ENTRY(h, &private_voutput->commit_handler_list, link) {
+ if (h->func == func && h->user_data == user_data) {
+ TDM_ERR("can't add twice");
+ return TDM_ERROR_BAD_REQUEST;
+ }
+ }
+
+ h = calloc(1, sizeof *h);
+ TDM_RETURN_VAL_IF_FAIL(h != NULL, TDM_ERROR_OUT_OF_MEMORY);
+
+ 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;
+ }
+
+ h->private_voutput = private_voutput;
+ h->func = func;
+ h->user_data = user_data;
+ LIST_ADDTAIL(&h->link, &private_voutput->commit_handler_list);
+ LIST_INITHEAD(&h->call_link);
+
+ pthread_mutex_unlock(&private_client->lock);
+
+ return TDM_ERROR_NONE;
+}
+
+void
+tdm_client_voutput_remove_commit_handler(tdm_client_voutput *voutput,
+ tdm_client_voutput_commit_handler func,
+ void *user_data)
+{
+ tdm_private_client_voutput *private_voutput;
+ tdm_private_client *private_client;
+ tdm_client_voutput_commit_handler_info *h = NULL;
+
+ TDM_RETURN_IF_FAIL(voutput != NULL);
+ TDM_RETURN_IF_FAIL(func != NULL);
+
+ private_voutput = (tdm_private_client_voutput *)voutput;
+ private_client = private_voutput->base.private_client;
+
+ pthread_mutex_lock(&private_client->lock);
+
+ LIST_FOR_EACH_ENTRY(h, &private_voutput->commit_handler_list, link) {
+ if (h->func != func || h->user_data != user_data)
+ continue;
+
+ LIST_DEL(&h->link);
+ free(h);
+
+ pthread_mutex_unlock(&private_client->lock);
+ }
+
+ pthread_mutex_unlock(&private_client->lock);
+}
+
+tdm_error
+tdm_client_voutput_commit_done(tdm_client_voutput *voutput)
+{
+ tdm_private_client_voutput *private_voutput;
+
+ TDM_RETURN_VAL_IF_FAIL(voutput != NULL, TDM_ERROR_INVALID_PARAMETER);
+
+ private_voutput = (tdm_private_client_voutput *)voutput;
+ wl_tdm_voutput_commit_done(private_voutput->wl_voutput);
+
+ return TDM_ERROR_NONE;
+}
+
tdm_client_output *
tdm_client_voutput_get_client_output(tdm_client_voutput *voutput, tdm_error *error)
{
ASSERT_EQ(ret, TDM_ERROR_INVALID_PARAMETER);
}
+static void
+_tc_tdm_client_voutput_commit_handler(tdm_client_voutput *voutput, void *user_data)
+{
+ int *flag;
+ flag = (int *)user_data;
+ *flag = 1;
+}
+
+TEST_F(TDMVirtualOutput, AddCommitHandler)
+{
+ tdm_error ret;
+ int flag_callback_called = 0;
+
+ ret = tdm_client_voutput_add_commit_handler(this->voutput,
+ _tc_tdm_client_voutput_commit_handler,
+ &flag_callback_called);
+ ASSERT_EQ(ret, TDM_ERROR_NONE);
+// ASSERT_EQ(flag_callback_called, 1);
+
+ tdm_client_voutput_remove_commit_handler(this->voutput,
+ _tc_tdm_client_voutput_commit_handler,
+ &flag_callback_called);
+}
+
+TEST_F(TDMVirtualOutput, CommitDone)
+{
+ tdm_error ret;
+
+ ret = tdm_client_voutput_commit_done(this->voutput);
+ ASSERT_EQ(ret, TDM_ERROR_NONE);
+}
+
TEST_F(TDMVirtualOutput, GetClientOutput)
{
tdm_error ret;