mirror of
https://gitlab.freedesktop.org/pipewire/pipewire
synced 2024-07-09 04:05:58 +00:00
move PIPEWIRE_PROPS to stream and filter
Make all streams and filters handle PIPEWIRE_PROPS. The order for applying stream/filter properties is: 1) application provided properties. 2) generic config. 3) match rules. 4) environment variables (PIPEWIRE_PROPS, ...) from generic to more specific. 5) defaults.
This commit is contained in:
parent
5a023c8c84
commit
61d318125e
|
@ -473,7 +473,6 @@ static int snd_pcm_pipewire_prepare(snd_pcm_ioplug_t *io)
|
|||
snd_pcm_pipewire_t *pw = io->private_data;
|
||||
snd_pcm_sw_params_t *swparams;
|
||||
const struct spa_pod *params[1];
|
||||
const char *str;
|
||||
uint8_t buffer[1024];
|
||||
struct spa_pod_builder b = SPA_POD_BUILDER_INIT(buffer, sizeof(buffer));
|
||||
struct pw_properties *props;
|
||||
|
@ -504,11 +503,7 @@ static int snd_pcm_pipewire_prepare(snd_pcm_ioplug_t *io)
|
|||
pw->stream = NULL;
|
||||
}
|
||||
|
||||
props = NULL;
|
||||
if ((str = getenv("PIPEWIRE_PROPS")) != NULL)
|
||||
props = pw_properties_new_string(str);
|
||||
if (props == NULL)
|
||||
props = pw_properties_new(NULL, NULL);
|
||||
props = pw_properties_new(NULL, NULL);
|
||||
if (props == NULL)
|
||||
goto error;
|
||||
|
||||
|
|
|
@ -3228,9 +3228,6 @@ jack_client_t * jack_client_open (const char *client_name,
|
|||
pw_context_conf_update_props(client->context.context,
|
||||
"jack.properties", client->props);
|
||||
|
||||
if ((str = getenv("PIPEWIRE_PROPS")) != NULL)
|
||||
pw_properties_update_string(client->props, str, strlen(str));
|
||||
|
||||
pw_context_conf_section_match_rules(client->context.context, "jack.rules",
|
||||
&client->props->dict, execute_match, client);
|
||||
|
||||
|
@ -3321,10 +3318,8 @@ jack_client_t * jack_client_open (const char *client_name,
|
|||
&client->registry_listener,
|
||||
®istry_events, client);
|
||||
|
||||
if ((str = getenv("PIPEWIRE_LATENCY")) != NULL)
|
||||
pw_properties_set(client->props, PW_KEY_NODE_LATENCY, str);
|
||||
if ((str = getenv("PIPEWIRE_RATE")) != NULL)
|
||||
pw_properties_set(client->props, PW_KEY_NODE_RATE, str);
|
||||
if ((str = getenv("PIPEWIRE_PROPS")) != NULL)
|
||||
pw_properties_update_string(client->props, str, strlen(str));
|
||||
if ((str = getenv("PIPEWIRE_QUANTUM")) != NULL) {
|
||||
struct spa_fraction q;
|
||||
if (sscanf(str, "%u/%u", &q.num, &q.denom) == 2 && q.denom != 0) {
|
||||
|
@ -3336,6 +3331,11 @@ jack_client_t * jack_client_open (const char *client_name,
|
|||
pw_log_warn("invalid PIPEWIRE_QUANTUM: %s", str);
|
||||
}
|
||||
}
|
||||
if ((str = getenv("PIPEWIRE_LATENCY")) != NULL)
|
||||
pw_properties_set(client->props, PW_KEY_NODE_LATENCY, str);
|
||||
if ((str = getenv("PIPEWIRE_RATE")) != NULL)
|
||||
pw_properties_set(client->props, PW_KEY_NODE_RATE, str);
|
||||
|
||||
if ((str = pw_properties_get(client->props, PW_KEY_NODE_LATENCY)) != NULL) {
|
||||
uint32_t num, denom;
|
||||
if (sscanf(str, "%u/%u", &num, &denom) == 2 && denom != 0) {
|
||||
|
|
|
@ -1426,7 +1426,6 @@ static int connect_stream(struct file *file)
|
|||
{
|
||||
int res;
|
||||
struct global *g = file->node;
|
||||
const char *str;
|
||||
struct timespec abstime;
|
||||
const char *error = NULL;
|
||||
uint8_t buffer[1024];
|
||||
|
@ -1442,11 +1441,7 @@ static int connect_stream(struct file *file)
|
|||
|
||||
disconnect_stream(file);
|
||||
|
||||
props = NULL;
|
||||
if ((str = getenv("PIPEWIRE_PROPS")) != NULL)
|
||||
props = pw_properties_new_string(str);
|
||||
if (props == NULL)
|
||||
props = pw_properties_new(NULL, NULL);
|
||||
props = pw_properties_new(NULL, NULL);
|
||||
if (props == NULL) {
|
||||
res = -errno;
|
||||
goto exit;
|
||||
|
@ -1470,6 +1465,7 @@ static int connect_stream(struct file *file)
|
|||
&file->stream_listener,
|
||||
&stream_events, file);
|
||||
|
||||
|
||||
file->error = 0;
|
||||
|
||||
pw_stream_connect(file->stream,
|
||||
|
|
|
@ -1211,20 +1211,16 @@ filter_new(struct pw_context *context, const char *name,
|
|||
res = -errno;
|
||||
goto error_properties;
|
||||
}
|
||||
spa_hook_list_init(&impl->hooks);
|
||||
this->properties = props;
|
||||
|
||||
pw_context_conf_update_props(context, "filter.properties", props);
|
||||
|
||||
if (pw_properties_get(props, PW_KEY_NODE_NAME) == NULL && extra) {
|
||||
str = pw_properties_get(extra, PW_KEY_APP_NAME);
|
||||
if (str == NULL)
|
||||
str = pw_properties_get(extra, PW_KEY_APP_PROCESS_BINARY);
|
||||
if (str == NULL)
|
||||
str = name;
|
||||
pw_properties_set(props, PW_KEY_NODE_NAME, str);
|
||||
}
|
||||
if ((str = getenv("PIPEWIRE_LATENCY")) != NULL)
|
||||
pw_properties_set(props, PW_KEY_NODE_LATENCY, str);
|
||||
if ((str = getenv("PIPEWIRE_RATE")) != NULL)
|
||||
pw_properties_set(props, PW_KEY_NODE_RATE, str);
|
||||
pw_context_conf_section_match_rules(impl->context, "filter.rules",
|
||||
&this->properties->dict, execute_match, this);
|
||||
|
||||
if ((str = getenv("PIPEWIRE_PROPS")) != NULL)
|
||||
pw_properties_update_string(props, str, strlen(str));
|
||||
if ((str = getenv("PIPEWIRE_QUANTUM")) != NULL) {
|
||||
struct spa_fraction q;
|
||||
if (sscanf(str, "%u/%u", &q.num, &q.denom) == 2 && q.denom != 0) {
|
||||
|
@ -1234,12 +1230,19 @@ filter_new(struct pw_context *context, const char *name,
|
|||
"%u/%u", q.num, q.denom);
|
||||
}
|
||||
}
|
||||
if ((str = getenv("PIPEWIRE_LATENCY")) != NULL)
|
||||
pw_properties_set(props, PW_KEY_NODE_LATENCY, str);
|
||||
if ((str = getenv("PIPEWIRE_RATE")) != NULL)
|
||||
pw_properties_set(props, PW_KEY_NODE_RATE, str);
|
||||
|
||||
spa_hook_list_init(&impl->hooks);
|
||||
this->properties = props;
|
||||
|
||||
pw_context_conf_section_match_rules(impl->context, "filter.rules",
|
||||
&this->properties->dict, execute_match, this);
|
||||
if (pw_properties_get(props, PW_KEY_NODE_NAME) == NULL && extra) {
|
||||
str = pw_properties_get(extra, PW_KEY_APP_NAME);
|
||||
if (str == NULL)
|
||||
str = pw_properties_get(extra, PW_KEY_APP_PROCESS_BINARY);
|
||||
if (str == NULL)
|
||||
str = name;
|
||||
pw_properties_set(props, PW_KEY_NODE_NAME, str);
|
||||
}
|
||||
|
||||
this->name = name ? strdup(name) : NULL;
|
||||
this->node_id = SPA_ID_INVALID;
|
||||
|
|
|
@ -1411,23 +1411,16 @@ stream_new(struct pw_context *context, const char *name,
|
|||
res = -errno;
|
||||
goto error_properties;
|
||||
}
|
||||
spa_hook_list_init(&impl->hooks);
|
||||
this->properties = props;
|
||||
|
||||
pw_context_conf_update_props(context, "stream.properties", props);
|
||||
|
||||
if (pw_properties_get(props, PW_KEY_STREAM_IS_LIVE) == NULL)
|
||||
pw_properties_set(props, PW_KEY_STREAM_IS_LIVE, "true");
|
||||
pw_context_conf_section_match_rules(context, "stream.rules",
|
||||
&this->properties->dict, execute_match, this);
|
||||
|
||||
if (pw_properties_get(props, PW_KEY_NODE_NAME) == NULL && extra) {
|
||||
str = pw_properties_get(extra, PW_KEY_APP_NAME);
|
||||
if (str == NULL)
|
||||
str = pw_properties_get(extra, PW_KEY_APP_PROCESS_BINARY);
|
||||
if (str == NULL)
|
||||
str = name;
|
||||
pw_properties_set(props, PW_KEY_NODE_NAME, str);
|
||||
}
|
||||
if ((str = getenv("PIPEWIRE_LATENCY")) != NULL)
|
||||
pw_properties_set(props, PW_KEY_NODE_LATENCY, str);
|
||||
if ((str = getenv("PIPEWIRE_RATE")) != NULL)
|
||||
pw_properties_set(props, PW_KEY_NODE_RATE, str);
|
||||
if ((str = getenv("PIPEWIRE_PROPS")) != NULL)
|
||||
pw_properties_update_string(props, str, strlen(str));
|
||||
if ((str = getenv("PIPEWIRE_QUANTUM")) != NULL) {
|
||||
struct spa_fraction q;
|
||||
if (sscanf(str, "%u/%u", &q.num, &q.denom) == 2 && q.denom != 0) {
|
||||
|
@ -1437,11 +1430,21 @@ stream_new(struct pw_context *context, const char *name,
|
|||
"%u/%u", q.num, q.denom);
|
||||
}
|
||||
}
|
||||
spa_hook_list_init(&impl->hooks);
|
||||
this->properties = props;
|
||||
if ((str = getenv("PIPEWIRE_LATENCY")) != NULL)
|
||||
pw_properties_set(props, PW_KEY_NODE_LATENCY, str);
|
||||
if ((str = getenv("PIPEWIRE_RATE")) != NULL)
|
||||
pw_properties_set(props, PW_KEY_NODE_RATE, str);
|
||||
|
||||
pw_context_conf_section_match_rules(context, "stream.rules",
|
||||
&this->properties->dict, execute_match, this);
|
||||
if (pw_properties_get(props, PW_KEY_STREAM_IS_LIVE) == NULL)
|
||||
pw_properties_set(props, PW_KEY_STREAM_IS_LIVE, "true");
|
||||
if (pw_properties_get(props, PW_KEY_NODE_NAME) == NULL && extra) {
|
||||
str = pw_properties_get(extra, PW_KEY_APP_NAME);
|
||||
if (str == NULL)
|
||||
str = pw_properties_get(extra, PW_KEY_APP_PROCESS_BINARY);
|
||||
if (str == NULL)
|
||||
str = name;
|
||||
pw_properties_set(props, PW_KEY_NODE_NAME, str);
|
||||
}
|
||||
|
||||
this->name = name ? strdup(name) : NULL;
|
||||
this->node_id = SPA_ID_INVALID;
|
||||
|
|
Loading…
Reference in New Issue
Block a user