From fd544712496c0f5268f536818cabb24be6071623 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Wed, 1 Feb 2017 17:48:12 +0100 Subject: [PATCH] Implement SYNC message A sync message returns a notify-done after all request are finished and can be used to wait for completion of a bunch of commands. Use it wait for all proxy BIND requests to complete so that we can look at the info immediately. Copy the default value of unset properties. --- pinos/client/connection.c | 6 +----- pinos/client/context.c | 14 ++++++++++++-- pinos/gst/gstpinosdeviceprovider.c | 2 +- pinos/server/core.c | 13 +++++++++++++ spa/lib/props.c | 18 ++++++++++-------- 5 files changed, 37 insertions(+), 16 deletions(-) diff --git a/pinos/client/connection.c b/pinos/client/connection.c index a4680028e..9ec101d84 100644 --- a/pinos/client/connection.c +++ b/pinos/client/connection.c @@ -81,11 +81,7 @@ connection_add_fd (PinosConnection *conn, return index; } -#if 1 -#define PINOS_DEBUG_MESSAGE(format,args...) pinos_log_debug(format,##args) -#else -#define PINOS_DEBUG_MESSAGE(format,args...) -#endif +#define PINOS_DEBUG_MESSAGE(format,args...) pinos_log_trace(format,##args) static void connection_parse_client_update (PinosConnection *conn, PinosMessageClientUpdate *m) diff --git a/pinos/client/context.c b/pinos/client/context.c index 26402e775..c6ee574af 100644 --- a/pinos/client/context.c +++ b/pinos/client/context.c @@ -132,8 +132,17 @@ core_dispatch_func (void *object, { PinosMessageNotifyDone *nd = message; - if (nd->seq == 0) + if (nd->seq == 0) { + PinosMessageSync sync; + + sync.seq = 1; + pinos_proxy_send_message (this->core_proxy, + PINOS_MESSAGE_SYNC, + &sync, + true); + } else if (nd->seq == 1) { context_set_state (this, PINOS_CONTEXT_STATE_CONNECTED, NULL); + } break; } case PINOS_MESSAGE_ERROR: @@ -776,7 +785,8 @@ do_list (PinosContext *context, if (proxy->type != type) continue; - cb (context, SPA_RESULT_OK, proxy->user_data, user_data); + if (proxy->user_data) + cb (context, SPA_RESULT_OK, proxy->user_data, user_data); } cb (context, SPA_RESULT_ENUM_END, NULL, user_data); } diff --git a/pinos/gst/gstpinosdeviceprovider.c b/pinos/gst/gstpinosdeviceprovider.c index 63b6a4400..ae2812770 100644 --- a/pinos/gst/gstpinosdeviceprovider.c +++ b/pinos/gst/gstpinosdeviceprovider.c @@ -202,7 +202,7 @@ new_node (const PinosNodeInfo *info) GstPinosDeviceType type; int i; - caps = gst_caps_new_empty(); + caps = gst_caps_new_empty (); if (info->max_inputs > 0 && info->max_outputs == 0) { type = GST_PINOS_DEVICE_TYPE_SINK; diff --git a/pinos/server/core.c b/pinos/server/core.c index 4a2fab589..794e3f49b 100644 --- a/pinos/server/core.c +++ b/pinos/server/core.c @@ -101,6 +101,19 @@ core_dispatch_func (void *object, m->props); break; } + case PINOS_MESSAGE_SYNC: + { + PinosMessageSync *m = message; + PinosMessageNotifyDone r; + + r.seq = m->seq; + pinos_client_send_message (client, + resource, + PINOS_MESSAGE_NOTIFY_DONE, + &r, + true); + break; + } case PINOS_MESSAGE_GET_REGISTRY: { diff --git a/spa/lib/props.c b/spa/lib/props.c index ac3301b3d..56c3e4519 100644 --- a/spa/lib/props.c +++ b/spa/lib/props.c @@ -80,25 +80,27 @@ spa_props_copy_values (const SpaProps *src, SpaProps *dest) { int i; - SpaResult res; if (src == dest) return SPA_RESULT_OK; for (i = 0; i < dest->n_prop_info; i++) { - const SpaPropInfo *info = &dest->prop_info[i]; - SpaPropValue value; + const SpaPropInfo *dinfo = &dest->prop_info[i]; + const SpaPropInfo *sinfo; + unsigned int idx; - if (!(info->flags & SPA_PROP_FLAG_WRITABLE)) + if (!(dinfo->flags & SPA_PROP_FLAG_WRITABLE)) continue; - if ((res = spa_props_get_value (src, spa_props_index_for_id (src, info->id), &value)) < 0) + if ((idx = spa_props_index_for_id (src, dinfo->id)) == SPA_IDX_INVALID) continue; - if (value.size > info->maxsize) + sinfo = &src->prop_info[idx]; + if (sinfo->maxsize > dinfo->maxsize) return SPA_RESULT_WRONG_PROPERTY_SIZE; - memcpy (SPA_MEMBER (dest, info->offset, void), value.value, value.size); + memcpy (SPA_MEMBER (dest, dinfo->offset, void), SPA_MEMBER (src, sinfo->offset, void), sinfo->maxsize); - SPA_PROPS_INDEX_SET (dest, i); + if (!SPA_PROPS_INDEX_IS_UNSET (src, idx)) + SPA_PROPS_INDEX_SET (dest, i); } return SPA_RESULT_OK; }