Skip to content

mixer-control: set max_volume to PA_VOLUME_NORM if no valid volume

After freshly installing the ubuntu 20.04, we open a gnome-terminal and press Tab button, the system will output a bell notification sound, then we open the gnome-control-center and check the sound page, we could find the output volume of 'System Sounds' is 0, but the notification sound still could be outputted with max output volume.

Another way to reproduce it is after freshly installing the ubuntu 20.04, open the gnome-control-center directly and change to the sound page, we could find the output volume of 'System Sounds' is max, then we click any 'Alert Sound' button at the bottom of the page, the sound is outputted with max volume and the output volume of 'System Sounds' is becoming to 0 from UI, and even it is 0, the notification sound still could be outputted with max volume.

This issue has something to do with libgnome-volume-control and pulseaudio. After freshly installing the system, there is no saved entry for "sink-input-by-media-role:event" in module-stream-restore of PA, so the libg-v-c will compose a pa_ext_stream_restore_info in the _pa_ext_stream_restore_read_cb(), when a notification sound stream is sent to PA, PA will create an entry with name of "sink-input-by-media-role:event" and save it to the database, but the volume_valid is false until gnome calls pa_ext_stream_restore_write(). So if users open the gnome-control-center before calling the pa_ext_stream_restore_write(), although there is an entry with the name of "sink-input-by-media-role:event" in the module-stream-restore, but the volume is not valid in that entry, if calling pa_cvolume_max (&info->volume), it will returns 0. In this case, the libg-v-c reports the max_volume is 0 to gnome layers, but in the PA, the stream/sink-input volume is max (pa_sink_input_new() of the sink-input.c).

To fix it, we add checking in the libg-v-c, if info->volume.channels is 0, it means the volume is not valid in the entry, we set the max_volume to PA_VOLUME_NORM like _pa_ext_stream_restore_read_cb() does in this case.

Below is the PA log about the stream entry without a valid volume:

E: [pulseaudio] module-stream-restore.c: name=sink-input-by-media-role:event

E: [pulseaudio] module-stream-restore.c: device=(null) no

E: [pulseaudio] module-stream-restore.c: channel_map=(invalid)

E: [pulseaudio] module-stream-restore.c: volume=(invalid) no

E: [pulseaudio] module-stream-restore.c: mute=no no

Signed-off-by: Hui Wang hui.wang@canonical.com

Edited by Hui Wang

Merge request reports