mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-07 13:30:03 -05:00
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:
parent
cb78d6f57c
commit
3650346f70
15 changed files with 57 additions and 43 deletions
|
|
@ -1322,12 +1322,11 @@ static void sink_input_detach_cb(pa_sink_input *i) {
|
|||
}
|
||||
}
|
||||
|
||||
/* Called from source I/O thread context. */
|
||||
/* Called from source I/O thread context except when cork() is called without valid source. */
|
||||
static void source_output_state_change_cb(pa_source_output *o, pa_source_output_state_t state) {
|
||||
struct userdata *u;
|
||||
|
||||
pa_source_output_assert_ref(o);
|
||||
pa_source_output_assert_io_context(o);
|
||||
pa_assert_se(u = o->userdata);
|
||||
|
||||
pa_log_debug("Source output %d state %d", o->index, state);
|
||||
|
|
@ -1345,7 +1344,7 @@ static void sink_input_state_change_cb(pa_sink_input *i, pa_sink_input_state_t s
|
|||
/* If we are added for the first time, ask for a rewinding so that
|
||||
* we are heard right-away. */
|
||||
if (PA_SINK_INPUT_IS_LINKED(state) &&
|
||||
i->thread_info.state == PA_SINK_INPUT_INIT) {
|
||||
i->thread_info.state == PA_SINK_INPUT_INIT && i->sink) {
|
||||
pa_log_debug("Requesting rewind due to state change.");
|
||||
pa_sink_input_request_rewind(i, 0, false, true, true);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -860,7 +860,7 @@ static void sink_input_state_change_cb(pa_sink_input *i, pa_sink_input_state_t s
|
|||
/* If we are added for the first time, ask for a rewinding so that
|
||||
* we are heard right-away. */
|
||||
if (PA_SINK_INPUT_IS_LINKED(state) &&
|
||||
i->thread_info.state == PA_SINK_INPUT_INIT) {
|
||||
i->thread_info.state == PA_SINK_INPUT_INIT && i->sink) {
|
||||
pa_log_debug("Requesting rewind due to state change.");
|
||||
pa_sink_input_request_rewind(i, 0, false, true, true);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -633,7 +633,7 @@ static void sink_input_state_change_cb(pa_sink_input *i, pa_sink_input_state_t s
|
|||
/* If we are added for the first time, ask for a rewinding so that
|
||||
* we are heard right-away. */
|
||||
if (PA_SINK_INPUT_IS_LINKED(state) &&
|
||||
i->thread_info.state == PA_SINK_INPUT_INIT) {
|
||||
i->thread_info.state == PA_SINK_INPUT_INIT && i->sink) {
|
||||
pa_log_debug("Requesting rewind due to state change.");
|
||||
pa_sink_input_request_rewind(i, 0, false, true, true);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -496,15 +496,14 @@ static void source_output_detach_cb(pa_source_output *o) {
|
|||
}
|
||||
}
|
||||
|
||||
/* Called from input thread context */
|
||||
/* Called from input thread context except when cork() is called without valid source. */
|
||||
static void source_output_state_change_cb(pa_source_output *o, pa_source_output_state_t state) {
|
||||
struct userdata *u;
|
||||
|
||||
pa_source_output_assert_ref(o);
|
||||
pa_source_output_assert_io_context(o);
|
||||
pa_assert_se(u = o->userdata);
|
||||
|
||||
if (PA_SOURCE_OUTPUT_IS_LINKED(state) && o->thread_info.state == PA_SOURCE_OUTPUT_INIT) {
|
||||
if (PA_SOURCE_OUTPUT_IS_LINKED(state) && o->thread_info.state == PA_SOURCE_OUTPUT_INIT && o->source) {
|
||||
|
||||
u->skip = pa_usec_to_bytes(PA_CLIP_SUB(pa_source_get_latency_within_thread(o->source),
|
||||
u->latency),
|
||||
|
|
|
|||
|
|
@ -283,7 +283,7 @@ static void sink_input_state_change_cb(pa_sink_input *i, pa_sink_input_state_t s
|
|||
/* If we are added for the first time, ask for a rewinding so that
|
||||
* we are heard right-away. */
|
||||
if (PA_SINK_INPUT_IS_LINKED(state) &&
|
||||
i->thread_info.state == PA_SINK_INPUT_INIT) {
|
||||
i->thread_info.state == PA_SINK_INPUT_INIT && i->sink) {
|
||||
pa_log_debug("Requesting rewind due to state change.");
|
||||
pa_sink_input_request_rewind(i, 0, false, true, true);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -222,12 +222,11 @@ static void source_output_kill_cb(pa_source_output *o) {
|
|||
pa_module_unload_request(u->module, true);
|
||||
}
|
||||
|
||||
/* Called from output thread context */
|
||||
/* Called from output thread context except when cork() is called without valid source. */
|
||||
static void source_output_state_change_cb(pa_source_output *o, pa_source_output_state_t state) {
|
||||
struct userdata *u;
|
||||
|
||||
pa_source_output_assert_ref(o);
|
||||
pa_source_output_assert_io_context(o);
|
||||
pa_assert_se(u = o->userdata);
|
||||
|
||||
pa_log_debug("Source output %d state %d.", o->index, state);
|
||||
|
|
|
|||
|
|
@ -112,7 +112,7 @@ static void sink_input_state_change_cb(pa_sink_input *i, pa_sink_input_state_t s
|
|||
/* If we are added for the first time, ask for a rewinding so that
|
||||
* we are heard right-away. */
|
||||
if (PA_SINK_INPUT_IS_LINKED(state) &&
|
||||
i->thread_info.state == PA_SINK_INPUT_INIT)
|
||||
i->thread_info.state == PA_SINK_INPUT_INIT && i->sink)
|
||||
pa_sink_input_request_rewind(i, 0, false, true, true);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -409,7 +409,7 @@ static void sink_input_state_change_cb(pa_sink_input *i, pa_sink_input_state_t s
|
|||
/* If we are added for the first time, ask for a rewinding so that
|
||||
* we are heard right-away. */
|
||||
if (PA_SINK_INPUT_IS_LINKED(state) &&
|
||||
i->thread_info.state == PA_SINK_INPUT_INIT) {
|
||||
i->thread_info.state == PA_SINK_INPUT_INIT && i->sink) {
|
||||
pa_log_debug("Requesting rewind due to state change.");
|
||||
pa_sink_input_request_rewind(i, 0, false, true, true);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -391,17 +391,16 @@ static void source_output_detach_cb(pa_source_output *o) {
|
|||
pa_source_set_rtpoll(u->source, NULL);
|
||||
}
|
||||
|
||||
/* Called from output thread context */
|
||||
/* Called from output thread context except when cork() is called without valid source.*/
|
||||
static void source_output_state_change_cb(pa_source_output *o, pa_source_output_state_t state) {
|
||||
struct userdata *u;
|
||||
|
||||
pa_source_output_assert_ref(o);
|
||||
pa_source_output_assert_io_context(o);
|
||||
pa_assert_se(u = o->userdata);
|
||||
|
||||
/* FIXME */
|
||||
#if 0
|
||||
if (PA_SOURCE_OUTPUT_IS_LINKED(state) && o->thread_info.state == PA_SOURCE_OUTPUT_INIT) {
|
||||
if (PA_SOURCE_OUTPUT_IS_LINKED(state) && o->thread_info.state == PA_SOURCE_OUTPUT_INIT && o->source) {
|
||||
|
||||
u->skip = pa_usec_to_bytes(PA_CLIP_SUB(pa_source_get_latency_within_thread(o->source),
|
||||
u->latency),
|
||||
|
|
|
|||
|
|
@ -421,7 +421,7 @@ static void sink_input_state_change_cb(pa_sink_input *i, pa_sink_input_state_t s
|
|||
/* If we are added for the first time, ask for a rewinding so that
|
||||
* we are heard right-away. */
|
||||
if (PA_SINK_INPUT_IS_LINKED(state) &&
|
||||
i->thread_info.state == PA_SINK_INPUT_INIT) {
|
||||
i->thread_info.state == PA_SINK_INPUT_INIT && i->sink) {
|
||||
pa_log_debug("Requesting rewind due to state change.");
|
||||
pa_sink_input_request_rewind(i, 0, false, true, true);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue