diff --git a/src/modules/module-protocol-pulse/pulse-server.c b/src/modules/module-protocol-pulse/pulse-server.c index 12ffed1c1..e8cf29d79 100644 --- a/src/modules/module-protocol-pulse/pulse-server.c +++ b/src/modules/module-protocol-pulse/pulse-server.c @@ -1127,6 +1127,15 @@ 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 */ + if (stream->create_tag == SPA_ID_INVALID || !stream->corked) { + if (old == PW_STREAM_STATE_PAUSED && state == PW_STREAM_STATE_STREAMING) + stream_send_suspended(stream, false); + if (old == PW_STREAM_STATE_STREAMING && state == PW_STREAM_STATE_PAUSED) + stream_send_suspended(stream, true); + } + if (destroy_stream) { pw_work_queue_add(impl->work_queue, stream, 0, do_destroy_stream, NULL); diff --git a/src/modules/module-protocol-pulse/stream.c b/src/modules/module-protocol-pulse/stream.c index 9426428d2..7d0ac0cf4 100644 --- a/src/modules/module-protocol-pulse/stream.c +++ b/src/modules/module-protocol-pulse/stream.c @@ -314,6 +314,31 @@ int stream_send_started(struct stream *stream) return client_queue_message(client, reply); } +int stream_send_suspended(struct stream *stream, bool suspended) +{ + struct client *client = stream->client; + struct impl *impl = client->impl; + struct message *reply; + uint32_t command; + + pw_log_debug("client %p [%s]: stream %p SUSPENDED channel:%u", + client, client->name, stream, stream->channel); + + command = stream->direction == PW_DIRECTION_OUTPUT ? + COMMAND_PLAYBACK_STREAM_SUSPENDED : + COMMAND_RECORD_STREAM_SUSPENDED; + + reply = message_alloc(impl, -1, 0); + message_put(reply, + TAG_U32, command, + TAG_U32, -1, + TAG_U32, stream->channel, + TAG_BOOLEAN, suspended, + TAG_INVALID); + + return client_queue_message(client, reply); +} + int stream_send_request(struct stream *stream) { struct client *client = stream->client; diff --git a/src/modules/module-protocol-pulse/stream.h b/src/modules/module-protocol-pulse/stream.h index 64ecea680..3d017f391 100644 --- a/src/modules/module-protocol-pulse/stream.h +++ b/src/modules/module-protocol-pulse/stream.h @@ -114,6 +114,7 @@ int stream_send_underflow(struct stream *stream, int64_t offset); int stream_send_overflow(struct stream *stream); int stream_send_killed(struct stream *stream); int stream_send_started(struct stream *stream); +int stream_send_suspended(struct stream *stream, bool suspended); int stream_send_request(struct stream *stream); int stream_update_minreq(struct stream *stream, uint32_t minreq); int stream_send_moved(struct stream *stream, uint32_t peer_index, const char *peer_name);