sink-input/source-output: Don't crash when cork() is called without valid sink or source

If pa_sink_input_cork() or pa_source_output_cork() were called without a sink
or source attached, the calls would crash pulseaudio.

This patch fixes the problem, so that a source output or sink input can still
be corked or uncorked while source or sink are invalid. This is needed to
correct the corking logic in module-loopback.
This commit is contained in:
Georg Chini 2017-03-29 07:10:28 +02:00
parent cb78d6f57c
commit 3650346f70
15 changed files with 57 additions and 43 deletions

View file

@ -284,7 +284,7 @@ static pa_hook_result_t sink_input_state_changed_hook_cb(pa_core *c, pa_sink_inp
pa_assert(u);
state = pa_sink_input_get_state(s);
if (state == PA_SINK_INPUT_RUNNING || state == PA_SINK_INPUT_DRAINED)
if ((state == PA_SINK_INPUT_RUNNING || state == PA_SINK_INPUT_DRAINED) && s->sink)
if ((d = pa_hashmap_get(u->device_infos, s->sink)))
resume(d);
@ -296,7 +296,7 @@ static pa_hook_result_t source_output_state_changed_hook_cb(pa_core *c, pa_sourc
pa_source_output_assert_ref(s);
pa_assert(u);
if (pa_source_output_get_state(s) == PA_SOURCE_OUTPUT_RUNNING) {
if (pa_source_output_get_state(s) == PA_SOURCE_OUTPUT_RUNNING && s->source) {
struct device_info *d;
if (s->source->monitor_of)