diff --git a/src/modules/module-protocol-pulse/pulse-server.c b/src/modules/module-protocol-pulse/pulse-server.c index 9098f2a79..020c36cd1 100644 --- a/src/modules/module-protocol-pulse/pulse-server.c +++ b/src/modules/module-protocol-pulse/pulse-server.c @@ -1743,6 +1743,8 @@ static int do_create_playback_stream(struct client *client, uint32_t command, ui stream->is_underrun = true; stream->underrun_for = -1; + pw_properties_set(props, "pulse.corked", corked ? "true" : "false"); + if (rate != 0) { struct spa_fraction lat; fix_playback_buffer_attr(stream, &attr, ss_rate, &lat); @@ -2016,6 +2018,8 @@ static int do_create_record_stream(struct client *client, uint32_t command, uint if (client->quirks & QUIRK_REMOVE_CAPTURE_DONT_MOVE) no_move = false; + pw_properties_set(props, "pulse.corked", corked ? "true" : "false"); + if (rate != 0) { struct spa_fraction lat; fix_record_buffer_attr(stream, &attr, ss_rate, &lat); @@ -2625,8 +2629,7 @@ static int do_cork_stream(struct client *client, uint32_t command, uint32_t tag, if (stream == NULL || stream->type == STREAM_TYPE_UPLOAD) return -ENOENT; - stream->corked = cork; - stream_set_paused(stream, cork, "cork request"); + stream_set_corked(stream, cork); if (cork) { stream->is_underrun = true; } else { @@ -4012,6 +4015,7 @@ static int fill_sink_input_info(struct client *client, struct message *m, uint32_t module_id = SPA_ID_INVALID, client_id = SPA_ID_INVALID; uint32_t peer_index; struct device_info dev_info; + bool corked; if (!pw_manager_object_is_sink_input(o) || info == NULL || info->props == NULL) return -ENOENT; @@ -4039,6 +4043,10 @@ static int fill_sink_input_info(struct client *client, struct message *m, else peer_index = SPA_ID_INVALID; } + if ((str = spa_dict_lookup(info->props, "pulse.corked")) != NULL) + corked = spa_atob(str); + else + corked = dev_info.state != STATE_RUNNING; message_put(m, TAG_U32, o->index, /* sink_input index */ @@ -4064,7 +4072,7 @@ static int fill_sink_input_info(struct client *client, struct message *m, TAG_INVALID); if (client->version >= 19) message_put(m, - TAG_BOOLEAN, dev_info.state != STATE_RUNNING, /* corked */ + TAG_BOOLEAN, corked, /* corked */ TAG_INVALID); if (client->version >= 20) message_put(m, @@ -4091,6 +4099,7 @@ static int fill_source_output_info(struct client *client, struct message *m, uint32_t module_id = SPA_ID_INVALID, client_id = SPA_ID_INVALID; uint32_t peer_index; struct device_info dev_info; + bool corked; if (!pw_manager_object_is_source_output(o) || info == NULL || info->props == NULL) return -ENOENT; @@ -4118,6 +4127,10 @@ static int fill_source_output_info(struct client *client, struct message *m, else peer_index = SPA_ID_INVALID; } + if ((str = spa_dict_lookup(info->props, "pulse.corked")) != NULL) + corked = spa_atob(str); + else + corked = dev_info.state != STATE_RUNNING; message_put(m, TAG_U32, o->index, /* source_output index */ @@ -4138,7 +4151,7 @@ static int fill_source_output_info(struct client *client, struct message *m, TAG_INVALID); if (client->version >= 19) message_put(m, - TAG_BOOLEAN, dev_info.state != STATE_RUNNING, /* corked */ + TAG_BOOLEAN, corked, /* corked */ TAG_INVALID); if (client->version >= 22) { struct format_info fi; diff --git a/src/modules/module-protocol-pulse/stream.c b/src/modules/module-protocol-pulse/stream.c index 94d1fdd9d..e3b8b7b0f 100644 --- a/src/modules/module-protocol-pulse/stream.c +++ b/src/modules/module-protocol-pulse/stream.c @@ -211,6 +211,16 @@ void stream_set_paused(struct stream *stream, bool paused, const char *reason) pw_stream_set_active(stream->stream, !paused); } +void stream_set_corked(struct stream *stream, bool cork) +{ + stream->corked = cork; + pw_log_info("cork %d", cork); + pw_stream_update_properties(stream->stream, + &SPA_DICT_ITEMS( + SPA_DICT_ITEM("pulse.corked", cork ? "true" : "false"))); + stream_set_paused(stream, cork, "cork request"); +} + int stream_send_underflow(struct stream *stream, int64_t offset) { struct client *client = stream->client; diff --git a/src/modules/module-protocol-pulse/stream.h b/src/modules/module-protocol-pulse/stream.h index b0522ea49..64ecea680 100644 --- a/src/modules/module-protocol-pulse/stream.h +++ b/src/modules/module-protocol-pulse/stream.h @@ -107,6 +107,7 @@ void stream_free(struct stream *stream); void stream_flush(struct stream *stream); uint32_t stream_pop_missing(struct stream *stream); +void stream_set_corked(struct stream *stream, bool corked); void stream_set_paused(struct stream *stream, bool paused, const char *reason); int stream_send_underflow(struct stream *stream, int64_t offset);