module: proxy latency params

This commit is contained in:
Wim Taymans 2021-05-27 16:07:25 +02:00
parent c319ed68d1
commit 06cf1e1c00
2 changed files with 98 additions and 4 deletions

View file

@ -202,10 +202,40 @@ static void capture_process(void *d)
process(impl);
}
static void input_param_latency_changed(struct impl *impl, const struct spa_pod *param)
{
struct spa_latency_info latency;
uint8_t buffer[1024];
struct spa_pod_builder b;
const struct spa_pod *params[1];
if (spa_latency_parse(param, &latency) < 0)
return;
spa_pod_builder_init(&b, buffer, sizeof(buffer));
params[0] = spa_latency_build(&b, SPA_PARAM_Latency, &latency);
if (latency.direction == SPA_DIRECTION_INPUT)
pw_stream_update_params(impl->source, params, 1);
else
pw_stream_update_params(impl->capture, params, 1);
}
static void input_param_changed(void *data, uint32_t id, const struct spa_pod *param)
{
struct impl *impl = data;
switch (id) {
case SPA_PARAM_Latency:
input_param_latency_changed(impl, param);
break;
}
}
static const struct pw_stream_events capture_events = {
PW_VERSION_STREAM_EVENTS,
.destroy = capture_destroy,
.process = capture_process
.process = capture_process,
.param_changed = input_param_changed
};
static void source_destroy(void *d)
@ -218,8 +248,38 @@ static void source_destroy(void *d)
static const struct pw_stream_events source_events = {
PW_VERSION_STREAM_EVENTS,
.destroy = source_destroy,
.param_changed = input_param_changed
};
static void output_param_latency_changed(struct impl *impl, const struct spa_pod *param)
{
struct spa_latency_info latency;
uint8_t buffer[1024];
struct spa_pod_builder b;
const struct spa_pod *params[1];
if (spa_latency_parse(param, &latency) < 0)
return;
spa_pod_builder_init(&b, buffer, sizeof(buffer));
params[0] = spa_latency_build(&b, SPA_PARAM_Latency, &latency);
if (latency.direction == SPA_DIRECTION_INPUT)
pw_stream_update_params(impl->source, params, 1);
else
pw_stream_update_params(impl->capture, params, 1);
}
static void output_param_changed(void *data, uint32_t id, const struct spa_pod *param)
{
struct impl *impl = data;
switch (id) {
case SPA_PARAM_Latency:
output_param_latency_changed(impl, param);
break;
}
}
static void sink_destroy(void *d)
{
struct impl *impl = d;
@ -245,11 +305,13 @@ static void playback_destroy(void *d)
static const struct pw_stream_events playback_events = {
PW_VERSION_STREAM_EVENTS,
.destroy = playback_destroy,
.param_changed = output_param_changed
};
static const struct pw_stream_events sink_events = {
PW_VERSION_STREAM_EVENTS,
.destroy = sink_destroy,
.process = sink_process
.process = sink_process,
.param_changed = output_param_changed
};
static int setup_streams(struct impl *impl)