loopback: pass all latency to the other stream

Latency configured on one streams needs to be passed directly to the
other stream.
This commit is contained in:
Wim Taymans 2021-08-02 11:46:53 +02:00
parent f71529cbaf
commit 7d9dde0a1d

View file

@ -165,7 +165,8 @@ static void capture_process(void *d)
pw_stream_queue_buffer(impl->playback, out); pw_stream_queue_buffer(impl->playback, out);
} }
static void param_latency_changed(struct impl *impl, const struct spa_pod *param) static void param_latency_changed(struct impl *impl, const struct spa_pod *param,
struct pw_stream *other)
{ {
struct spa_latency_info latency; struct spa_latency_info latency;
uint8_t buffer[1024]; uint8_t buffer[1024];
@ -177,20 +178,16 @@ static void param_latency_changed(struct impl *impl, const struct spa_pod *param
spa_pod_builder_init(&b, buffer, sizeof(buffer)); spa_pod_builder_init(&b, buffer, sizeof(buffer));
params[0] = spa_latency_build(&b, SPA_PARAM_Latency, &latency); params[0] = spa_latency_build(&b, SPA_PARAM_Latency, &latency);
pw_stream_update_params(other, params, 1);
if (latency.direction == SPA_DIRECTION_INPUT)
pw_stream_update_params(impl->capture, params, 1);
else
pw_stream_update_params(impl->playback, params, 1);
} }
static void param_changed(void *data, uint32_t id, const struct spa_pod *param) static void capture_param_changed(void *data, uint32_t id, const struct spa_pod *param)
{ {
struct impl *impl = data; struct impl *impl = data;
switch (id) { switch (id) {
case SPA_PARAM_Latency: case SPA_PARAM_Latency:
param_latency_changed(impl, param); param_latency_changed(impl, param, impl->playback);
break; break;
} }
} }
@ -199,7 +196,7 @@ static const struct pw_stream_events in_stream_events = {
PW_VERSION_STREAM_EVENTS, PW_VERSION_STREAM_EVENTS,
.destroy = capture_destroy, .destroy = capture_destroy,
.process = capture_process, .process = capture_process,
.param_changed = param_changed, .param_changed = capture_param_changed,
}; };
static void playback_destroy(void *d) static void playback_destroy(void *d)
@ -209,10 +206,20 @@ static void playback_destroy(void *d)
impl->playback = NULL; impl->playback = NULL;
} }
static void playback_param_changed(void *data, uint32_t id, const struct spa_pod *param)
{
struct impl *impl = data;
switch (id) {
case SPA_PARAM_Latency:
param_latency_changed(impl, param, impl->capture);
break;
}
}
static const struct pw_stream_events out_stream_events = { static const struct pw_stream_events out_stream_events = {
PW_VERSION_STREAM_EVENTS, PW_VERSION_STREAM_EVENTS,
.destroy = playback_destroy, .destroy = playback_destroy,
.param_changed = param_changed, .param_changed = playback_param_changed,
}; };
static int setup_streams(struct impl *impl) static int setup_streams(struct impl *impl)