mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-03 09:01:54 -05:00
modules: reuse the same code for setting properties
We can reuse the same code for setting input and output stream properties. This also makes it possible to set the debug.aec.wav-path on all streams, like the properties say.
This commit is contained in:
parent
fbaf4db6b0
commit
658b624a83
1 changed files with 28 additions and 45 deletions
|
|
@ -677,25 +677,16 @@ static int set_params(struct impl* impl, const struct spa_pod *params)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void input_param_changed(void *data, uint32_t id, const struct spa_pod* param)
|
static void props_changed(struct impl* impl, const struct spa_pod *param)
|
||||||
{
|
{
|
||||||
struct spa_pod_object* obj = (struct spa_pod_object*)param;
|
|
||||||
const struct spa_pod_prop* prop;
|
|
||||||
struct impl* impl = data;
|
|
||||||
|
|
||||||
switch (id) {
|
|
||||||
case SPA_PARAM_Format:
|
|
||||||
if (param == NULL)
|
|
||||||
reset_buffers(impl);
|
|
||||||
break;
|
|
||||||
case SPA_PARAM_Latency:
|
|
||||||
input_param_latency_changed(impl, param);
|
|
||||||
break;
|
|
||||||
case SPA_PARAM_Props:
|
|
||||||
if (param != NULL) {
|
|
||||||
uint8_t buffer[1024];
|
uint8_t buffer[1024];
|
||||||
struct spa_pod_dynamic_builder b;
|
struct spa_pod_dynamic_builder b;
|
||||||
const struct spa_pod* params[1];
|
const struct spa_pod* params[1];
|
||||||
|
const struct spa_pod_prop* prop;
|
||||||
|
struct spa_pod_object* obj = (struct spa_pod_object*)param;
|
||||||
|
|
||||||
|
if (param == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
SPA_POD_OBJECT_FOREACH(obj, prop) {
|
SPA_POD_OBJECT_FOREACH(obj, prop) {
|
||||||
if (prop->key == SPA_PROP_params)
|
if (prop->key == SPA_PROP_params)
|
||||||
|
|
@ -710,9 +701,22 @@ static void input_param_changed(void *data, uint32_t id, const struct spa_pod* p
|
||||||
pw_stream_update_params(impl->playback, params, 1);
|
pw_stream_update_params(impl->playback, params, 1);
|
||||||
}
|
}
|
||||||
spa_pod_dynamic_builder_clean(&b);
|
spa_pod_dynamic_builder_clean(&b);
|
||||||
} else {
|
|
||||||
pw_log_warn("param is null");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void input_param_changed(void *data, uint32_t id, const struct spa_pod* param)
|
||||||
|
{
|
||||||
|
struct impl* impl = data;
|
||||||
|
|
||||||
|
switch (id) {
|
||||||
|
case SPA_PARAM_Format:
|
||||||
|
if (param == NULL)
|
||||||
|
reset_buffers(impl);
|
||||||
|
break;
|
||||||
|
case SPA_PARAM_Latency:
|
||||||
|
input_param_latency_changed(impl, param);
|
||||||
|
break;
|
||||||
|
case SPA_PARAM_Props:
|
||||||
|
props_changed(impl, param);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -785,8 +789,6 @@ static void output_param_latency_changed(struct impl *impl, const struct spa_pod
|
||||||
|
|
||||||
static void output_param_changed(void *data, uint32_t id, const struct spa_pod *param)
|
static void output_param_changed(void *data, uint32_t id, const struct spa_pod *param)
|
||||||
{
|
{
|
||||||
struct spa_pod_object *obj = (struct spa_pod_object *) param;
|
|
||||||
const struct spa_pod_prop *prop;
|
|
||||||
struct impl *impl = data;
|
struct impl *impl = data;
|
||||||
|
|
||||||
switch (id) {
|
switch (id) {
|
||||||
|
|
@ -798,26 +800,7 @@ static void output_param_changed(void *data, uint32_t id, const struct spa_pod *
|
||||||
output_param_latency_changed(impl, param);
|
output_param_latency_changed(impl, param);
|
||||||
break;
|
break;
|
||||||
case SPA_PARAM_Props:
|
case SPA_PARAM_Props:
|
||||||
if (param != NULL) {
|
props_changed(impl, param);
|
||||||
uint8_t buffer[1024];
|
|
||||||
struct spa_pod_dynamic_builder b;
|
|
||||||
const struct spa_pod* params[1];
|
|
||||||
|
|
||||||
SPA_POD_OBJECT_FOREACH(obj, prop)
|
|
||||||
{
|
|
||||||
if (prop->key == SPA_PROP_params) {
|
|
||||||
spa_audio_aec_set_params(impl->aec, &prop->value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
spa_pod_dynamic_builder_init(&b, buffer, sizeof(buffer), 4096);
|
|
||||||
params[0] = get_props_param(impl, &b.b);
|
|
||||||
if (params[0] != NULL) {
|
|
||||||
pw_stream_update_params(impl->capture, params, 1);
|
|
||||||
if (impl->playback != NULL)
|
|
||||||
pw_stream_update_params(impl->playback, params, 1);
|
|
||||||
}
|
|
||||||
spa_pod_dynamic_builder_clean(&b);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue