When source or sink changes, the sink input rate has to be reset to the initial value. --- src/modules/module-loopback.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/modules/module-loopback.c b/src/modules/module-loopback.c index c54b531..c773a98 100644 --- a/src/modules/module-loopback.c +++ b/src/modules/module-loopback.c @@ -539,7 +539,12 @@ static bool source_output_may_move_to_cb(pa_source_output *o, pa_source *dest) { if (!u->sink_input || !u->sink_input->sink) return true; - return dest != u->sink_input->sink->monitor_source; + /* We may still be adjusting, so reset rate to default before moving the source */ + if (dest != u->sink_input->sink->monitor_source) { + pa_sink_input_set_rate(u->sink_input, u->source_output->sample_spec.rate); + return true; + } + return false; } /* Called from main thread */ @@ -912,7 +917,16 @@ static bool sink_input_may_move_to_cb(pa_sink_input *i, pa_sink *dest) { if (!u->source_output || !u->source_output->source) return true; - return dest != u->source_output->source->monitor_of; + if (dest == u->source_output->source->monitor_of) + return false; + + /* We may still be adjusting, so reset rate to default before moving the sink. + * If the sink is not valid (profile change), only update the sink input sample spec. */ + if (u->sink_input->sink) + pa_sink_input_set_rate(u->sink_input, u->source_output->sample_spec.rate); + else + u->sink_input->sample_spec.rate = u->source_output->sample_spec.rate; + return true; } /* Called from output thread context */ -- 2.8.1