mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-08 13:30:08 -05:00
modules: parse and set control values
This commit is contained in:
parent
0a966d4637
commit
3272344df4
1 changed files with 27 additions and 2 deletions
|
|
@ -193,6 +193,7 @@ static void set_control_value(struct impl *impl, const char *name, float value)
|
||||||
for (i = 0; i < impl->n_control; i++) {
|
for (i = 0; i < impl->n_control; i++) {
|
||||||
uint32_t p = impl->control[i];
|
uint32_t p = impl->control[i];
|
||||||
if (strcmp(impl->desc->PortNames[p], name) == 0) {
|
if (strcmp(impl->desc->PortNames[p], name) == 0) {
|
||||||
|
pw_log_info("set '%s' to %f", name, value);
|
||||||
impl->control_data[i] = value;
|
impl->control_data[i] = value;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -202,8 +203,32 @@ static void set_control_value(struct impl *impl, const char *name, float value)
|
||||||
static void param_changed(void *data, uint32_t id, const struct spa_pod *param)
|
static void param_changed(void *data, uint32_t id, const struct spa_pod *param)
|
||||||
{
|
{
|
||||||
struct impl *impl = data;
|
struct impl *impl = data;
|
||||||
pw_log_info("%p: %d changed", impl, id);
|
const struct spa_pod_prop *prop;
|
||||||
spa_debug_pod(0, NULL, param);
|
struct spa_pod_parser prs;
|
||||||
|
struct spa_pod_frame f;
|
||||||
|
|
||||||
|
if (id != SPA_PARAM_Props)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if ((prop = spa_pod_find_prop(param, NULL, SPA_PROP_paramStruct)) == NULL ||
|
||||||
|
!spa_pod_is_struct(&prop->value))
|
||||||
|
return;
|
||||||
|
|
||||||
|
spa_pod_parser_pod(&prs, &prop->value);
|
||||||
|
if (spa_pod_parser_push_struct(&prs, &f) < 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
while (true) {
|
||||||
|
const char *name;
|
||||||
|
float value;
|
||||||
|
|
||||||
|
if (spa_pod_parser_get_string(&prs, &name) < 0)
|
||||||
|
break;
|
||||||
|
if (spa_pod_parser_get_float(&prs, &value) < 0)
|
||||||
|
break;
|
||||||
|
|
||||||
|
set_control_value(impl, name, value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct pw_stream_events in_stream_events = {
|
static const struct pw_stream_events in_stream_events = {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue