[pulseaudio-discuss] [PATCH 2/2] loopback: Reset sink input rate when source or sink changes
Georg Chini
georg at chini.tk
Mon Apr 10 20:13:28 UTC 2017
If source or sink are changed, the current sink input rate may be different
from the default rate. Switch sink input rate back to default to avoid the
influence of the previous combination of source and sink.
---
src/modules/module-loopback.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/src/modules/module-loopback.c b/src/modules/module-loopback.c
index 2242c62c..2a0d7075 100644
--- a/src/modules/module-loopback.c
+++ b/src/modules/module-loopback.c
@@ -644,6 +644,11 @@ static void source_output_moving_cb(pa_source_output *o, pa_source *dest) {
pa_asyncmsgq_send(u->sink_input->sink->asyncmsgq, PA_MSGOBJECT(u->sink_input), SINK_INPUT_MESSAGE_SOURCE_CHANGED, NULL, 0, NULL);
else
u->output_thread_info.push_called = false;
+
+ /* The sampling rate may be far away from the default rate if we are still
+ * recovering from a previous source or sink change, so reset rate to
+ * default before moving the source. */
+ pa_sink_input_set_rate(u->sink_input, u->source_output->sample_spec.rate);
}
/* Called from main thread */
@@ -1008,6 +1013,11 @@ static void sink_input_moving_cb(pa_sink_input *i, pa_sink *dest) {
u->output_thread_info.pop_called = false;
u->output_thread_info.first_pop_done = false;
+
+ /* Sample rate may be far away from the default rate if we are still
+ * recovering from a previous source or sink change, so reset rate to
+ * default before moving the sink. */
+ pa_sink_input_set_rate(u->sink_input, u->source_output->sample_spec.rate);
}
/* Called from main thread */
--
2.11.0
More information about the pulseaudio-discuss
mailing list