summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWim Taymans <wtaymans@redhat.com>2019-11-27 12:19:28 +0100
committerWim Taymans <wtaymans@redhat.com>2019-11-29 13:34:09 +0100
commit8c067604809956762cac604664650844f6c20935 (patch)
tree8b24130dd0f16186077362ab7917f2a7cbd93b53
parent4361e5f32679aa761e264cfa7259c3665288ba5a (diff)
alsa-endpoint: monitor and update node params
-rw-r--r--src/examples/media-session/alsa-endpoint.c49
1 files changed, 49 insertions, 0 deletions
diff --git a/src/examples/media-session/alsa-endpoint.c b/src/examples/media-session/alsa-endpoint.c
index 58253b67..3e45a609 100644
--- a/src/examples/media-session/alsa-endpoint.c
+++ b/src/examples/media-session/alsa-endpoint.c
@@ -248,8 +248,55 @@ static struct stream *endpoint_add_stream(struct endpoint *endpoint)
return s;
}
+static void update_params(void *data)
+{
+ uint32_t n_params;
+ const struct spa_pod **params;
+ struct endpoint *endpoint = data;
+ struct sm_node *node = endpoint->obj->snode;
+ struct sm_param *p;
+
+ pw_log_debug(NAME" %p: endpoint", endpoint);
+
+ params = alloca(sizeof(struct spa_pod *) * node->n_params);
+ n_params = 0;
+ spa_list_for_each(p, &node->param_list, link) {
+ switch (p->id) {
+ case SPA_PARAM_Props:
+ case SPA_PARAM_PropInfo:
+ params[n_params++] = p->param;
+ break;
+ default:
+ break;
+ }
+ }
+
+ pw_client_endpoint_proxy_update(endpoint->client_endpoint,
+ PW_CLIENT_ENDPOINT_UPDATE_PARAMS |
+ PW_CLIENT_ENDPOINT_UPDATE_INFO,
+ n_params, params,
+ &endpoint->info);
+}
+
static struct endpoint *make_endpoint(struct alsa_node *obj, struct endpoint *monitor);
+static void object_update(void *data)
+{
+ struct endpoint *endpoint = data;
+ struct impl *impl = endpoint->obj->impl;
+ struct sm_node *node = endpoint->obj->snode;
+
+ pw_log_debug(NAME" %p: endpoint %p", impl, endpoint);
+
+ if (node->obj.changed & SM_NODE_CHANGE_MASK_PARAMS)
+ update_params(endpoint);
+}
+
+static const struct sm_object_events object_events = {
+ SM_VERSION_OBJECT_EVENTS,
+ .update = object_update
+};
+
static void complete_endpoint(void *data)
{
struct endpoint *endpoint = data;
@@ -300,6 +347,8 @@ static void complete_endpoint(void *data)
endpoint_add_stream(monitor);
}
stream_set_active(endpoint, stream, true);
+
+ sm_object_add_listener(&endpoint->obj->snode->obj, &endpoint->listener, &object_events, endpoint);
}
static struct endpoint *make_endpoint(struct alsa_node *obj, struct endpoint *monitor)