mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-02 09:01:46 -05:00
cork-on-phone: Only cork (and subsequently uncork) streams that are not already corked.
Although by "cork" I really mean "cork+mute" as that's what the module does. If e.g. Rhythmbox is paused when a phone call comes in, the current stream state will be corked and thus we should not track it for future uncorking when the phone call ends. Likewise if the stream is just muted (manually) we will not take any action either when the phone stream is seen first, nor when it disappears. Also add some additional debug messages.
This commit is contained in:
parent
e2df844976
commit
dda564f50b
1 changed files with 17 additions and 8 deletions
|
|
@ -66,8 +66,10 @@ static pa_bool_t shall_cork(pa_sink *s, pa_sink_input *ignore) {
|
|||
if (!(role = pa_proplist_gets(j->proplist, PA_PROP_MEDIA_ROLE)))
|
||||
continue;
|
||||
|
||||
if (pa_streq(role, "phone"))
|
||||
if (pa_streq(role, "phone")) {
|
||||
pa_log_debug("Found a phone stream that will trigger the auto-cork.");
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
|
|
@ -81,7 +83,7 @@ static void apply_cork(struct userdata *u, pa_sink *s, pa_sink_input *ignore, pa
|
|||
pa_sink_assert_ref(s);
|
||||
|
||||
for (j = PA_SINK_INPUT(pa_idxset_first(s->inputs, &idx)); j; j = PA_SINK_INPUT(pa_idxset_next(s->inputs, &idx))) {
|
||||
pa_bool_t corked;
|
||||
pa_bool_t corked, muted, corked_here;
|
||||
const char *role;
|
||||
|
||||
if (j == ignore)
|
||||
|
|
@ -94,18 +96,25 @@ static void apply_cork(struct userdata *u, pa_sink *s, pa_sink_input *ignore, pa
|
|||
!pa_streq(role, "music"))
|
||||
continue;
|
||||
|
||||
corked = !!pa_hashmap_get(u->cork_state, j);
|
||||
corked = (pa_sink_input_get_state(j) == PA_SINK_INPUT_CORKED);
|
||||
muted = pa_sink_input_get_mute(j);
|
||||
corked_here = !!pa_hashmap_get(u->cork_state, j);
|
||||
|
||||
if (cork && !corked) {
|
||||
pa_hashmap_put(u->cork_state, j, PA_INT_TO_PTR(1));
|
||||
if (cork && !corked && !muted) {
|
||||
pa_log_debug("Found a music/video stream that should be corked/muted.");
|
||||
if (!corked_here)
|
||||
pa_hashmap_put(u->cork_state, j, PA_INT_TO_PTR(1));
|
||||
pa_sink_input_set_mute(j, TRUE, FALSE);
|
||||
pa_sink_input_send_event(j, PA_STREAM_EVENT_REQUEST_CORK, NULL);
|
||||
} else if (!cork) {
|
||||
pa_hashmap_remove(u->cork_state, j);
|
||||
|
||||
if (corked) {
|
||||
pa_sink_input_set_mute(j, FALSE, FALSE);
|
||||
pa_sink_input_send_event(j, PA_STREAM_EVENT_REQUEST_UNCORK, NULL);
|
||||
if (corked_here && (corked || muted)) {
|
||||
pa_log_debug("Found a music/video stream that should be uncorked/unmuted.");
|
||||
if (muted)
|
||||
pa_sink_input_set_mute(j, FALSE, FALSE);
|
||||
if (corked)
|
||||
pa_sink_input_send_event(j, PA_STREAM_EVENT_REQUEST_UNCORK, NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue