Skip to content
Snippets Groups Projects
Commit b7576380 authored by Wim Taymans's avatar Wim Taymans
Browse files

module-pulse-tunnel: fix rate correction sign for capture

The capture delay calculation had the wrong sign, making the resampler
go in the wrong direction and causing pitch changes.

Fixes #3093
parent 106836f7
No related branches found
No related tags found
No related merge requests found
...@@ -232,17 +232,14 @@ static void stream_state_changed(void *d, enum pw_stream_state old, ...@@ -232,17 +232,14 @@ static void stream_state_changed(void *d, enum pw_stream_state old,
} }
} }
static void update_rate(struct impl *impl, bool playback) static void update_rate(struct impl *impl)
{ {
float error, corr; float error, corr;
if (impl->rate_match == NULL) if (impl->rate_match == NULL)
return; return;
if (playback) error = (float)impl->target_latency - (float)impl->current_latency;
error = (float)impl->target_latency - (float)impl->current_latency;
else
error = (float)impl->current_latency - (float)impl->target_latency;
error = SPA_CLAMP(error, -impl->max_error, impl->max_error); error = SPA_CLAMP(error, -impl->max_error, impl->max_error);
corr = spa_dll_update(&impl->dll, error); corr = spa_dll_update(&impl->dll, error);
...@@ -283,7 +280,7 @@ static void playback_stream_process(void *d) ...@@ -283,7 +280,7 @@ static void playback_stream_process(void *d)
size, RINGBUFFER_SIZE); size, RINGBUFFER_SIZE);
impl->resync = true; impl->resync = true;
} else { } else {
update_rate(impl, true); update_rate(impl);
} }
spa_ringbuffer_write_data(&impl->ring, spa_ringbuffer_write_data(&impl->ring,
impl->buffer, RINGBUFFER_SIZE, impl->buffer, RINGBUFFER_SIZE,
...@@ -324,7 +321,7 @@ static void capture_stream_process(void *d) ...@@ -324,7 +321,7 @@ static void capture_stream_process(void *d)
avail = impl->target_buffer; avail = impl->target_buffer;
index += avail - impl->target_buffer; index += avail - impl->target_buffer;
} else { } else {
update_rate(impl, false); update_rate(impl);
} }
spa_ringbuffer_read_data(&impl->ring, spa_ringbuffer_read_data(&impl->ring,
impl->buffer, RINGBUFFER_SIZE, impl->buffer, RINGBUFFER_SIZE,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment