From a4874abc46401d36c669e859e118a811c3240f1d Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Mon, 5 Oct 2020 21:11:51 +0200 Subject: [PATCH] pulse: restore volume and muted --- src/examples/media-session/pulse-bridge.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/examples/media-session/pulse-bridge.c b/src/examples/media-session/pulse-bridge.c index f50096915..b9c76f32f 100644 --- a/src/examples/media-session/pulse-bridge.c +++ b/src/examples/media-session/pulse-bridge.c @@ -300,6 +300,9 @@ struct stream { struct buffer_attr attr; uint32_t frame_size; + struct cvolume volume; + bool muted; + uint32_t drain_tag; unsigned int corked:1; unsigned int adjust_latency:1; @@ -1361,6 +1364,11 @@ static void stream_param_changed(void *data, uint32_t id, const struct spa_pod * stream->frame_size = sample_spec_frame_size(&stream->ss); if (stream->create_tag != SPA_ID_INVALID) { + float val = stream->muted ? 1.0f : 0.0f; + pw_stream_set_control(stream->stream, + SPA_PROP_channelVolumes, stream->volume.channels, stream->volume.values, + SPA_PROP_mute, 1, &val, + 0); if (stream->corked) pw_stream_set_active(stream->stream, false); if (stream->direction == PW_DIRECTION_OUTPUT) @@ -1655,6 +1663,8 @@ static int do_create_playback_stream(struct client *client, uint32_t command, ui stream->create_tag = tag; stream->ss = ss; stream->map = map; + stream->volume = volume; + stream->muted = muted; fix_playback_buffer_attr(stream, &attr); stream->attr = attr; @@ -2067,6 +2077,8 @@ static int do_set_stream_volume(struct client *client, uint32_t command, uint32_ if (stream == NULL) return -EINVAL; + stream->volume = volume; + pw_stream_set_control(stream->stream, SPA_PROP_channelVolumes, volume.channels, volume.values, 0); @@ -2096,8 +2108,9 @@ static int do_set_stream_mute(struct client *client, uint32_t command, uint32_t if (stream == NULL) return -EINVAL; - val = mute ? 1.0f : 0.0f; + stream->muted = mute; + val = mute ? 1.0f : 0.0f; pw_stream_set_control(stream->stream, SPA_PROP_mute, 1, &val, 0);