GNOME Bugzilla – Bug 789551
Unplugging headset with audio panel open mutes internal mic
Last modified: 2017-10-30 15:50:11 UTC
The bug was originally reported downstream here [1] against unity-control-center. The problem is not easy to reproduce with gnome-control-center, however I was able to reproduce it on Ubuntu Artful 17.10 (Gnome Session, running gnome-control-center) once after serveral tries. Reproduce steps: 1. Open System Settings -> Sound -> select the input tab 2. Plug headset and select Headset on Unknown Audio Device dialog. 3. Check external mic is working 4. Adjust the internal microphone volume. (Just change the volume value.) 5. Adjust headset input volume around 100% in Input tab from Sound settings 6. Unplug headset 7. Check internet mic status In a nuthshell the problem is that g-c-c decides which port the system should use after the user unplugs the headset. In my opinion this should be PA's job. g-c-c should react to changes notified by PA and "update PA status" just if there is an user interaction with the GUI. Technically the problem is caused by the fact that removing the selected row from a treeview generates a selection-changed signal. Using row-activated event prenvents this. [1] https://bugs.launchpad.net/ubuntu/+source/unity-control-center/+bug/1716359
Created attachment 362403 [details] [review] sound: Use row-activated instead of selection-changed. Right now the tree view in the input and the output tab uses the "selection-changed" signal. This implies that when a row is removed (e.g. when unplugging heaphones) g-c-c will receive the signal and try to change the active port. G-c-c should not be the one deciding deciding which port should be active, the user or PA are smart enough.
Review of attachment 362403 [details] [review]: IIUC, the problem is that when a mixer device is removed we remove it from the model and if it was active/selected, the tree view immediately selects a new one thus causing us to tell the mixer to activate this tree view implicitly selected device, right? In that case, it seems we could fix this by just change the selection mode to GTK_SELECTION_SINGLE instead of BROWSE. With this change the tree view wouldn't select anything implicitly and we would get the active_input/output_update() callback from the mixer where we would then select the PA determined device. My concern with switching to the row-activated signal is that we currently conflate selection with active which means that using key navigation users can switch the device by simply moving the selection. So, unless we change the UI to convey activeness differently I'd prefer the solution I proposed above.
Thanks for the review, I'll try the suggested fix and I'll let you know asap.
Thinking a bit more about it, GTK_SELECTION_SINGLE means the UI might end up looking "broken" since it allows for deselection. Perhaps an alternative would be to check if there's an input event in the selection changed handlers and bail out if there isn't one. Using gtk_get_current_event_device() would be best for this as it avoid the event copy.
gtk_get_current_event_device seems to work fine (_SINGLE didn't work, the event was still triggered).
Created attachment 362425 [details] [review] sound: Discard selection-changed events that are not triggered by the user The tree view in the input and the output tab uses the "selection-changed" signal. This implies that when a row is removed (e.g. when unplugging heaphones) g-c-c will receive the signal and try to change the active port. G-c-c should not be the one deciding deciding which port should be active, the user or PA are smart enough. We should descard selection-changed events that are not triggered by an user interaction.
Review of attachment 362425 [details] [review]: looks good, thanks
Attachment 362425 [details] pushed as dc46487 - sound: Discard selection-changed events that are not triggered by the user