Add PIPEWIRE_QUANTUM env variable

That tries to both set the buffersize and the samplerate of the graph.
Document them in README.md
Also add the same env variables to pw-stream and pw-filter.
This commit is contained in:
Wim Taymans 2022-01-23 11:21:18 +01:00
parent f4021c7f44
commit 0bc3d1444a
5 changed files with 43 additions and 5 deletions

View file

@ -48,6 +48,13 @@ applications:
expressed as a fraction of the samplerate,
like 256/48000, which uses 256 samples at a
samplerate of 48KHz for a latency of 5.33ms.
This function does not attempt to configure
the samplerate.
* `PIPEWIRE_RATE=<num/denom>` to configure a rate for the graph.
* `PIPEWIRE_QUANTUM=<num/denom>` to configure latency as a fraction and a
samplerate. This function will attempt to change
the graph samplerate and use the specified
<num> as the buffer size.
* `PIPEWIRE_NODE=<id>` to request a link to the specified node
### Using tools

View file

@ -3217,6 +3217,17 @@ jack_client_t * jack_client_open (const char *client_name,
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_QUANTUM")) != NULL) {
struct spa_fraction q;
if (sscanf(str, "%u/%u", &q.num, &q.denom) == 2 && q.denom != 0) {
pw_properties_setf(client->props, PW_KEY_NODE_RATE,
"1/%u", q.denom);
pw_properties_setf(client->props, PW_KEY_NODE_LATENCY,
"%u/%u", q.num, q.denom);
} else {
pw_log_warn("invalid PIPEWIRE_QUANTUM: %s", 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) {

View file

@ -66,13 +66,11 @@ shift $(( OPTIND - 1 ))
if [ -n "$PERIOD" ]; then
if [ -n "$SAMPLERATE" ]; then
PIPEWIRE_RATE="1/$SAMPLERATE"
export PIPEWIRE_RATE
PIPEWIRE_QUANTUM="$PERIOD/$SAMPLERATE"
else
SAMPLERATE=$DEFAULT_SAMPLERATE
PIPEWIRE_QUANTUM="$PERIOD/$DEFAULT_SAMPLERATE"
fi
PIPEWIRE_LATENCY="$PERIOD/$SAMPLERATE"
export PIPEWIRE_LATENCY
export PIPEWIRE_QUANTUM
fi
LD_LIBRARY_PATH='@LIBJACK_PATH@'"${LD_LIBRARY_PATH+":$LD_LIBRARY_PATH"}"
export LD_LIBRARY_PATH

View file

@ -1222,6 +1222,17 @@ filter_new(struct pw_context *context, const char *name,
}
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) {
struct spa_fraction q;
if (sscanf(str, "%u/%u", &q.num, &q.denom) == 2 && q.denom != 0) {
pw_properties_setf(props, PW_KEY_NODE_RATE,
"1/%u", q.denom);
pw_properties_setf(props, PW_KEY_NODE_LATENCY,
"%u/%u", q.num, q.denom);
}
}
spa_hook_list_init(&impl->hooks);
this->properties = props;

View file

@ -1358,6 +1358,17 @@ stream_new(struct pw_context *context, const char *name,
}
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) {
struct spa_fraction q;
if (sscanf(str, "%u/%u", &q.num, &q.denom) == 2 && q.denom != 0) {
pw_properties_setf(props, PW_KEY_NODE_RATE,
"1/%u", q.denom);
pw_properties_setf(props, PW_KEY_NODE_LATENCY,
"%u/%u", q.num, q.denom);
}
}
spa_hook_list_init(&impl->hooks);
this->properties = props;