From d52056d9cd4bb9100ed329507ccf4e9ca74648a7 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Mon, 25 May 2026 18:13:12 +0200 Subject: [PATCH] pulse-server: keep track of dont_inhibit_auto_suspend Keep the flag dont_inhibit_auto_suspend around and use it do decide when to send suspend messages to the client. We don't always want to send suspend messages when the stream state changes because that could happen because the stream was, for example, relinked. The intention of the suspend message is mostly for monitor streams that use the dont-inhibit flag and want to follow the suspend state of the sink. See #5273 --- src/modules/module-protocol-pulse/pulse-server.c | 10 ++++++---- src/modules/module-protocol-pulse/stream.h | 1 + 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/modules/module-protocol-pulse/pulse-server.c b/src/modules/module-protocol-pulse/pulse-server.c index 922ec5bf8..f0cb55da6 100644 --- a/src/modules/module-protocol-pulse/pulse-server.c +++ b/src/modules/module-protocol-pulse/pulse-server.c @@ -1164,16 +1164,16 @@ static void stream_state_changed(void *data, enum pw_stream_state old, break; } - /* Don't emit suspended if we are creating a corked stream, as that will have a quick - * RUNNING/SUSPENDED transition for initial negotiation */ + /* Only emit suspended if we are created and not a corked stream, this means the + * paused on our stream needs to be caused by the sink suspend or an unlink. */ if (stream->create_tag == SPA_ID_INVALID && !stream->corked) { if (old == PW_STREAM_STATE_PAUSED && state == PW_STREAM_STATE_STREAMING && - stream->is_suspended) { + stream->dont_inhibit_auto_suspend && stream->is_suspended) { stream_send_suspended(stream, false); stream->is_suspended = false; } if (old == PW_STREAM_STATE_STREAMING && state == PW_STREAM_STATE_PAUSED && - !stream->is_suspended) { + stream->dont_inhibit_auto_suspend && !stream->is_suspended) { if (stream->fail_on_suspend) { stream->killed = true; destroy_stream = true; @@ -1790,6 +1790,7 @@ static int do_create_playback_stream(struct client *client, uint32_t command, ui stream->is_underrun = true; stream->underrun_for = -1; stream->fail_on_suspend = fail_on_suspend; + stream->dont_inhibit_auto_suspend = dont_inhibit_auto_suspend; pw_properties_set(props, "pulse.corked", corked ? "true" : "false"); @@ -2066,6 +2067,7 @@ static int do_create_record_stream(struct client *client, uint32_t command, uint stream->muted = muted; stream->muted_set = muted_set; stream->fail_on_suspend = fail_on_suspend; + stream->dont_inhibit_auto_suspend = dont_inhibit_auto_suspend; if (client->quirks & QUIRK_REMOVE_CAPTURE_DONT_MOVE) no_move = false; diff --git a/src/modules/module-protocol-pulse/stream.h b/src/modules/module-protocol-pulse/stream.h index 022f0ee74..f5609da6b 100644 --- a/src/modules/module-protocol-pulse/stream.h +++ b/src/modules/module-protocol-pulse/stream.h @@ -101,6 +101,7 @@ struct stream { unsigned int is_paused:1; unsigned int fail_on_suspend:1; unsigned int is_suspended:1; + unsigned int dont_inhibit_auto_suspend:1; }; struct stream *stream_new(struct client *client, enum stream_type type, uint32_t create_tag,