From 20b52d2082f0adad126c6564577b4e69f340f7f4 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Tue, 23 Apr 2024 11:49:12 +0200 Subject: [PATCH] keys: add and use some loop keys --- pipewire-jack/src/pipewire-jack.c | 2 +- src/pipewire/data-loop.c | 6 +++--- src/pipewire/keys.h | 13 +++++++++++-- src/pipewire/loop.c | 2 +- test/test-loop.c | 2 +- 5 files changed, 17 insertions(+), 8 deletions(-) diff --git a/pipewire-jack/src/pipewire-jack.c b/pipewire-jack/src/pipewire-jack.c index 641b10591..3f3508666 100644 --- a/pipewire-jack/src/pipewire-jack.c +++ b/pipewire-jack/src/pipewire-jack.c @@ -3906,7 +3906,7 @@ jack_client_t * jack_client_open (const char *client_name, client->server_name = NULL; client->props = pw_properties_new( - "loop.cancel", "true", + PW_KEY_LOOP_CANCEL, "true", PW_KEY_REMOTE_NAME, client->server_name, PW_KEY_CLIENT_NAME, client_name, PW_KEY_CLIENT_API, "jack", diff --git a/src/pipewire/data-loop.c b/src/pipewire/data-loop.c index cdf3b9021..3cee8a2e7 100644 --- a/src/pipewire/data-loop.c +++ b/src/pipewire/data-loop.c @@ -112,11 +112,11 @@ static struct pw_data_loop *loop_new(struct pw_loop *loop, const struct spa_dict this->rt_prio = -1; if (props != NULL) { - if ((str = spa_dict_lookup(props, "loop.cancel")) != NULL) + if ((str = spa_dict_lookup(props, PW_KEY_LOOP_CANCEL)) != NULL) this->cancel = pw_properties_parse_bool(str); - if ((str = spa_dict_lookup(props, "loop.class")) != NULL) + if ((str = spa_dict_lookup(props, PW_KEY_LOOP_CLASS)) != NULL) class = str; - if ((str = spa_dict_lookup(props, "loop.rt-prio")) != NULL) + if ((str = spa_dict_lookup(props, PW_KEY_LOOP_RT_PRIO)) != NULL) this->rt_prio = atoi(str); if ((str = spa_dict_lookup(props, SPA_KEY_THREAD_NAME)) != NULL) name = str; diff --git a/src/pipewire/keys.h b/src/pipewire/keys.h index a9ca50ec2..d13c3a285 100644 --- a/src/pipewire/keys.h +++ b/src/pipewire/keys.h @@ -69,6 +69,15 @@ extern "C" { #define PW_KEY_CONFIG_OVERRIDE_PREFIX "config.override.prefix" /**< a config override prefix directory */ #define PW_KEY_CONFIG_OVERRIDE_NAME "config.override.name" /**< a config override file name */ +/* loop */ +#define PW_KEY_LOOP_NAME "loop.name" /**< the name of a loop */ +#define PW_KEY_LOOP_CLASS "loop.class" /**< the classes this loop handles, array of strings */ +#define PW_KEY_LOOP_RT_PRIO "loop.rt-prio" /**< realtime priority of the loop */ +#define PW_KEY_LOOP_CANCEL "loop.cancel" /**< if the loop can be canceled */ +#define PW_KEY_LOOP_RETRY_TIMEOUT "loop.retry-timeout" /**< when the loop invoke queue is full, the timeout + * in microseconds before retrying. + * default = 1 second, 0 = disable */ + /* context */ #define PW_KEY_CONTEXT_PROFILE_MODULES "context.profile.modules" /**< a context profile for modules, deprecated */ #define PW_KEY_USER_NAME "context.user-name" /**< The user name that runs pipewire */ @@ -183,8 +192,8 @@ extern "C" { #define PW_KEY_NODE_TRANSPORT_SYNC "node.transport.sync" /**< the node handles transport sync */ #define PW_KEY_NODE_DRIVER "node.driver" /**< node can drive the graph */ #define PW_KEY_NODE_ASYNC "node.async" /**< the node wants async scheduling */ -#define PW_KEY_NODE_LOOP_NAME "node.loop.name" /**< the loop name to run in */ -#define PW_KEY_NODE_LOOP_CLASS "node.loop.class" /**< the loop class to run in */ +#define PW_KEY_NODE_LOOP_NAME "node.loop.name" /**< the loop name fnmatch pattern to run in */ +#define PW_KEY_NODE_LOOP_CLASS "node.loop.class" /**< the loop class fnmatch pattern to run in */ #define PW_KEY_NODE_STREAM "node.stream" /**< node is a stream, the server side should * add a converter */ #define PW_KEY_NODE_VIRTUAL "node.virtual" /**< the node is some sort of virtual diff --git a/src/pipewire/loop.c b/src/pipewire/loop.c index a69c10cd1..64baaa7f2 100644 --- a/src/pipewire/loop.c +++ b/src/pipewire/loop.c @@ -128,7 +128,7 @@ struct pw_loop *pw_loop_new(const struct spa_dict *props) this->utils = iface; if (props != NULL) { - if ((str = spa_dict_lookup(props, "loop.name")) != NULL) + if ((str = spa_dict_lookup(props, PW_KEY_LOOP_NAME)) != NULL) name = str; } if (name) diff --git a/test/test-loop.c b/test/test-loop.c index be9563ae8..1b4db7dd6 100644 --- a/test/test-loop.c +++ b/test/test-loop.c @@ -387,7 +387,7 @@ static int ctwd_add_source(struct spa_loop *loop, bool async, uint32_t seq, PWTEST(cancel_thread_while_dispatching) { static const struct spa_dict_item data_loop_props_items[] = { - { "loop.cancel", "true" }, + { PW_KEY_LOOP_CANCEL, "true" }, }; static const struct spa_dict data_loop_props = SPA_DICT_INIT_ARRAY(data_loop_props_items);