[pulseaudio-commits] 2 commits - src/modules src/pulsecore

Georg Chini gchini at kemper.freedesktop.org
Tue Apr 11 19:50:16 UTC 2017


 src/modules/module-loopback.c |   10 ++++++++++
 src/pulsecore/sink-input.c    |    7 ++++++-
 2 files changed, 16 insertions(+), 1 deletion(-)

New commits:
commit d3d980ff497b8678fa54df9190a63f5563366d5d
Author: Georg Chini <georg at chini.tk>
Date:   Tue Apr 11 21:49:11 2017 +0200

    loopback: Reset sink input rate when source or sink changes
    
    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.

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 */

commit 96cae04cedd1e0e4fd996cf9ea4f7519a21fdc71
Author: Georg Chini <georg at chini.tk>
Date:   Tue Apr 11 21:48:31 2017 +0200

    sink-input: Allow sink_input_set_rate() to be called during a move
    
    During a move sink_input->sink is not valid. This leads to a crash when
    sink_input_set_rate() is called from the moving() callback. This patch
    fixes the problem.

diff --git a/src/pulsecore/sink-input.c b/src/pulsecore/sink-input.c
index d6ef57d3..bcc783ae 100644
--- a/src/pulsecore/sink-input.c
+++ b/src/pulsecore/sink-input.c
@@ -1580,7 +1580,12 @@ int pa_sink_input_set_rate(pa_sink_input *i, uint32_t rate) {
 
     i->sample_spec.rate = rate;
 
-    pa_asyncmsgq_post(i->sink->asyncmsgq, PA_MSGOBJECT(i), PA_SINK_INPUT_MESSAGE_SET_RATE, PA_UINT_TO_PTR(rate), 0, NULL, NULL);
+    if (i->sink)
+        pa_asyncmsgq_post(i->sink->asyncmsgq, PA_MSGOBJECT(i), PA_SINK_INPUT_MESSAGE_SET_RATE, PA_UINT_TO_PTR(rate), 0, NULL, NULL);
+    else {
+        i->thread_info.sample_spec.rate = rate;
+        pa_resampler_set_input_rate(i->thread_info.resampler, rate);
+    }
 
     pa_subscription_post(i->core, PA_SUBSCRIPTION_EVENT_SINK_INPUT|PA_SUBSCRIPTION_EVENT_CHANGE, i->index);
     return 0;



More information about the pulseaudio-commits mailing list