summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorg Chini <georg@chini.tk>2017-04-11 21:48:31 +0200
committerGeorg Chini <georg@chini.tk>2017-04-11 21:48:31 +0200
commit96cae04cedd1e0e4fd996cf9ea4f7519a21fdc71 (patch)
tree4974e8e0ee1e88933d0486f56bbc398bea79f5c4
parent5bc363d4b84ccbb07727d7d0603598a3b664b1b1 (diff)
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.
-rw-r--r--src/pulsecore/sink-input.c7
1 files changed, 6 insertions, 1 deletions
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;