suspend-on-idle: use earlier (safer) hooks for stream unlink notifications

In the "unlink post" hook it's not guaranteed that the stream's old
device exists any more, so let's use the "unlink" hook that is safer.
For example, module-bluetooth-policy does a card profile change in the
source-output "unlink post" hook, which invalidates the source-output's
source pointer.

When the "unlink" hook is fired, the stream is still linked to its
device, which affects the return values of the check_suspend()
functions. The unlinked streams should be ignored by the check_suspend()
functions, so I had to add extra parameters to those functions.
This commit is contained in:
Tanu Kaskinen 2016-10-12 17:20:40 +03:00
parent 2250dbfd69
commit c3393d27a5
5 changed files with 39 additions and 22 deletions

View file

@ -1943,7 +1943,7 @@ unsigned pa_source_used_by(pa_source *s) {
}
/* Called from main thread */
unsigned pa_source_check_suspend(pa_source *s) {
unsigned pa_source_check_suspend(pa_source *s, pa_source_output *ignore) {
unsigned ret;
pa_source_output *o;
uint32_t idx;
@ -1959,6 +1959,9 @@ unsigned pa_source_check_suspend(pa_source *s) {
PA_IDXSET_FOREACH(o, s->outputs, idx) {
pa_source_output_state_t st;
if (o == ignore)
continue;
st = pa_source_output_get_state(o);
/* We do not assert here. It is perfectly valid for a source output to