mirror of
https://gitlab.freedesktop.org/pipewire/pipewire
synced 2024-10-15 12:22:47 +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_pipewire_t *pw = io->private_data;
|
||||||
snd_pcm_sw_params_t *swparams;
|
snd_pcm_sw_params_t *swparams;
|
||||||
const struct spa_pod *params[1];
|
const struct spa_pod *params[1];
|
||||||
const char *str;
|
|
||||||
uint8_t buffer[1024];
|
uint8_t buffer[1024];
|
||||||
struct spa_pod_builder b = SPA_POD_BUILDER_INIT(buffer, sizeof(buffer));
|
struct spa_pod_builder b = SPA_POD_BUILDER_INIT(buffer, sizeof(buffer));
|
||||||
struct pw_properties *props;
|
struct pw_properties *props;
|
||||||
|
@ -504,10 +503,6 @@ static int snd_pcm_pipewire_prepare(snd_pcm_ioplug_t *io)
|
||||||
pw->stream = NULL;
|
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)
|
if (props == NULL)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
|
@ -3228,9 +3228,6 @@ jack_client_t * jack_client_open (const char *client_name,
|
||||||
pw_context_conf_update_props(client->context.context,
|
pw_context_conf_update_props(client->context.context,
|
||||||
"jack.properties", client->props);
|
"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",
|
pw_context_conf_section_match_rules(client->context.context, "jack.rules",
|
||||||
&client->props->dict, execute_match, client);
|
&client->props->dict, execute_match, client);
|
||||||
|
|
||||||
|
@ -3321,10 +3318,8 @@ jack_client_t * jack_client_open (const char *client_name,
|
||||||
&client->registry_listener,
|
&client->registry_listener,
|
||||||
®istry_events, client);
|
®istry_events, client);
|
||||||
|
|
||||||
if ((str = getenv("PIPEWIRE_LATENCY")) != NULL)
|
if ((str = getenv("PIPEWIRE_PROPS")) != NULL)
|
||||||
pw_properties_set(client->props, PW_KEY_NODE_LATENCY, str);
|
pw_properties_update_string(client->props, str, strlen(str));
|
||||||
if ((str = getenv("PIPEWIRE_RATE")) != NULL)
|
|
||||||
pw_properties_set(client->props, PW_KEY_NODE_RATE, str);
|
|
||||||
if ((str = getenv("PIPEWIRE_QUANTUM")) != NULL) {
|
if ((str = getenv("PIPEWIRE_QUANTUM")) != NULL) {
|
||||||
struct spa_fraction q;
|
struct spa_fraction q;
|
||||||
if (sscanf(str, "%u/%u", &q.num, &q.denom) == 2 && q.denom != 0) {
|
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);
|
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) {
|
if ((str = pw_properties_get(client->props, PW_KEY_NODE_LATENCY)) != NULL) {
|
||||||
uint32_t num, denom;
|
uint32_t num, denom;
|
||||||
if (sscanf(str, "%u/%u", &num, &denom) == 2 && denom != 0) {
|
if (sscanf(str, "%u/%u", &num, &denom) == 2 && denom != 0) {
|
||||||
|
|
|
@ -1426,7 +1426,6 @@ static int connect_stream(struct file *file)
|
||||||
{
|
{
|
||||||
int res;
|
int res;
|
||||||
struct global *g = file->node;
|
struct global *g = file->node;
|
||||||
const char *str;
|
|
||||||
struct timespec abstime;
|
struct timespec abstime;
|
||||||
const char *error = NULL;
|
const char *error = NULL;
|
||||||
uint8_t buffer[1024];
|
uint8_t buffer[1024];
|
||||||
|
@ -1442,10 +1441,6 @@ static int connect_stream(struct file *file)
|
||||||
|
|
||||||
disconnect_stream(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) {
|
if (props == NULL) {
|
||||||
res = -errno;
|
res = -errno;
|
||||||
|
@ -1470,6 +1465,7 @@ static int connect_stream(struct file *file)
|
||||||
&file->stream_listener,
|
&file->stream_listener,
|
||||||
&stream_events, file);
|
&stream_events, file);
|
||||||
|
|
||||||
|
|
||||||
file->error = 0;
|
file->error = 0;
|
||||||
|
|
||||||
pw_stream_connect(file->stream,
|
pw_stream_connect(file->stream,
|
||||||
|
|
|
@ -1211,20 +1211,16 @@ filter_new(struct pw_context *context, const char *name,
|
||||||
res = -errno;
|
res = -errno;
|
||||||
goto error_properties;
|
goto error_properties;
|
||||||
}
|
}
|
||||||
|
spa_hook_list_init(&impl->hooks);
|
||||||
|
this->properties = props;
|
||||||
|
|
||||||
pw_context_conf_update_props(context, "filter.properties", props);
|
pw_context_conf_update_props(context, "filter.properties", props);
|
||||||
|
|
||||||
if (pw_properties_get(props, PW_KEY_NODE_NAME) == NULL && extra) {
|
pw_context_conf_section_match_rules(impl->context, "filter.rules",
|
||||||
str = pw_properties_get(extra, PW_KEY_APP_NAME);
|
&this->properties->dict, execute_match, this);
|
||||||
if (str == NULL)
|
|
||||||
str = pw_properties_get(extra, PW_KEY_APP_PROCESS_BINARY);
|
if ((str = getenv("PIPEWIRE_PROPS")) != NULL)
|
||||||
if (str == NULL)
|
pw_properties_update_string(props, str, strlen(str));
|
||||||
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_QUANTUM")) != NULL) {
|
if ((str = getenv("PIPEWIRE_QUANTUM")) != NULL) {
|
||||||
struct spa_fraction q;
|
struct spa_fraction q;
|
||||||
if (sscanf(str, "%u/%u", &q.num, &q.denom) == 2 && q.denom != 0) {
|
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);
|
"%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);
|
if (pw_properties_get(props, PW_KEY_NODE_NAME) == NULL && extra) {
|
||||||
this->properties = props;
|
str = pw_properties_get(extra, PW_KEY_APP_NAME);
|
||||||
|
if (str == NULL)
|
||||||
pw_context_conf_section_match_rules(impl->context, "filter.rules",
|
str = pw_properties_get(extra, PW_KEY_APP_PROCESS_BINARY);
|
||||||
&this->properties->dict, execute_match, this);
|
if (str == NULL)
|
||||||
|
str = name;
|
||||||
|
pw_properties_set(props, PW_KEY_NODE_NAME, str);
|
||||||
|
}
|
||||||
|
|
||||||
this->name = name ? strdup(name) : NULL;
|
this->name = name ? strdup(name) : NULL;
|
||||||
this->node_id = SPA_ID_INVALID;
|
this->node_id = SPA_ID_INVALID;
|
||||||
|
|
|
@ -1411,23 +1411,16 @@ stream_new(struct pw_context *context, const char *name,
|
||||||
res = -errno;
|
res = -errno;
|
||||||
goto error_properties;
|
goto error_properties;
|
||||||
}
|
}
|
||||||
|
spa_hook_list_init(&impl->hooks);
|
||||||
|
this->properties = props;
|
||||||
|
|
||||||
pw_context_conf_update_props(context, "stream.properties", props);
|
pw_context_conf_update_props(context, "stream.properties", props);
|
||||||
|
|
||||||
if (pw_properties_get(props, PW_KEY_STREAM_IS_LIVE) == NULL)
|
pw_context_conf_section_match_rules(context, "stream.rules",
|
||||||
pw_properties_set(props, PW_KEY_STREAM_IS_LIVE, "true");
|
&this->properties->dict, execute_match, this);
|
||||||
|
|
||||||
if (pw_properties_get(props, PW_KEY_NODE_NAME) == NULL && extra) {
|
if ((str = getenv("PIPEWIRE_PROPS")) != NULL)
|
||||||
str = pw_properties_get(extra, PW_KEY_APP_NAME);
|
pw_properties_update_string(props, str, strlen(str));
|
||||||
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_QUANTUM")) != NULL) {
|
if ((str = getenv("PIPEWIRE_QUANTUM")) != NULL) {
|
||||||
struct spa_fraction q;
|
struct spa_fraction q;
|
||||||
if (sscanf(str, "%u/%u", &q.num, &q.denom) == 2 && q.denom != 0) {
|
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);
|
"%u/%u", q.num, q.denom);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
spa_hook_list_init(&impl->hooks);
|
if ((str = getenv("PIPEWIRE_LATENCY")) != NULL)
|
||||||
this->properties = props;
|
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",
|
if (pw_properties_get(props, PW_KEY_STREAM_IS_LIVE) == NULL)
|
||||||
&this->properties->dict, execute_match, this);
|
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->name = name ? strdup(name) : NULL;
|
||||||
this->node_id = SPA_ID_INVALID;
|
this->node_id = SPA_ID_INVALID;
|
||||||
|
|
Loading…
Reference in a new issue