pulse: restore volume and muted

This commit is contained in:
Wim Taymans 2020-10-05 21:11:51 +02:00
parent c81021a742
commit a4874abc46

View file

@ -300,6 +300,9 @@ struct stream {
struct buffer_attr attr; struct buffer_attr attr;
uint32_t frame_size; uint32_t frame_size;
struct cvolume volume;
bool muted;
uint32_t drain_tag; uint32_t drain_tag;
unsigned int corked:1; unsigned int corked:1;
unsigned int adjust_latency: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); stream->frame_size = sample_spec_frame_size(&stream->ss);
if (stream->create_tag != SPA_ID_INVALID) { 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) if (stream->corked)
pw_stream_set_active(stream->stream, false); pw_stream_set_active(stream->stream, false);
if (stream->direction == PW_DIRECTION_OUTPUT) 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->create_tag = tag;
stream->ss = ss; stream->ss = ss;
stream->map = map; stream->map = map;
stream->volume = volume;
stream->muted = muted;
fix_playback_buffer_attr(stream, &attr); fix_playback_buffer_attr(stream, &attr);
stream->attr = attr; stream->attr = attr;
@ -2067,6 +2077,8 @@ static int do_set_stream_volume(struct client *client, uint32_t command, uint32_
if (stream == NULL) if (stream == NULL)
return -EINVAL; return -EINVAL;
stream->volume = volume;
pw_stream_set_control(stream->stream, pw_stream_set_control(stream->stream,
SPA_PROP_channelVolumes, volume.channels, volume.values, SPA_PROP_channelVolumes, volume.channels, volume.values,
0); 0);
@ -2096,8 +2108,9 @@ static int do_set_stream_mute(struct client *client, uint32_t command, uint32_t
if (stream == NULL) if (stream == NULL)
return -EINVAL; return -EINVAL;
val = mute ? 1.0f : 0.0f; stream->muted = mute;
val = mute ? 1.0f : 0.0f;
pw_stream_set_control(stream->stream, pw_stream_set_control(stream->stream,
SPA_PROP_mute, 1, &val, SPA_PROP_mute, 1, &val,
0); 0);