GNOME Bugzilla – Bug 755062
Ask which type of sound device got plugged in
Last modified: 2016-02-16 16:42:25 UTC
Created attachment 311367 [details] jack_detect_windows.png When plugging in a headset, or a microphone in some computers, they will not be able to detect that there is a new input available (for the headset), or that it doesn't have any outputs (for the microphone). Ubuntu fixes this by popping up a dialogue asking which type of device got plugged in: http://voices.canonical.com/david.henningsson/2014/03/07/headset-jacks-on-newer-laptops/ Windows does something similar (see attached screenshot).
@Bastien, yep. Feel free to grab the code: http://bazaar.launchpad.net/~unity-settings-daemon-team/unity-settings-daemon/trunk/files/head:/plugins/media-keys/what-did-you-plug-in/ I can make it into a git patch against gnome-settings-daemon if you like, but I probably won't have time to fix it up a lot (i e, fixing coding style issues, if your design team wants the pixels to align differently, etc).
What hardware do we need to test this?
In short, most Haswell + Dell that has a combo jack. Here's a raw list of machines. It's generated from: http://git.kernel.org/cgit/linux/kernel/git/tiwai/hda-emu.git/tree/codecs/canonical grep "Headset Mic Phantom Jack" . -rl | sort ./alc255-dell-inspiron-3541-ccert-201403-14859 ./alc255-dell-inspiron-5447-ccert-201401-14529 ./alc255-dell-latitude-3340-ccert-201312-14380 ./alc255-dell-latitude-3340-ccert-201312-14381 ./alc283-dell-inspiron-14-7000-series-7437-ccert-201307-13932 ./alc283-dell-inspiron-15-7000-series-7537-ccert-201306-13868 ./alc283-dell-inspiron-17-7000-series-7737-ccert-201306-13870 ./alc283-dell-inspiron-3135-ccert-201308-14057 ./alc283-dell-inspiron-3135-ccert-201308-14155 ./alc283-dell-inspiron-3437-ccert-201304-13210 ./alc283-dell-inspiron-5435-ccert-201303-13114 ./alc283-dell-inspiron-5737-ccert-201305-13636 ./alc283-dell-inspiron-7537-ccert-201306-13867 ./alc283-dell-inspiron-7737-ccert-201306-13869 ./alc283-dell-latitude-3440-ccert-201306-13862 ./alc283-dell-latitude-3440-ccert-201306-13863 ./alc283-dell-latitude-3440-ccert-201307-13905 ./alc283-dell-latitude-3540-ccert-201306-13864 ./alc283-dell-latitude-3540-ccert-201306-13865 ./alc283-dell-latitude-3540-ccert-201306-13866 ./alc290-dell-vostro-5470-ccert-201307-14038 ./alc292-dell-latitude-e5440-ccert-201307-13941 ./alc292-dell-latitude-e5440-ccert-201307-14017 ./alc292-dell-latitude-e5540-ccert-201307-13942 ./alc292-dell-latitude-e5540-ccert-201307-14032 ./alc292-dell-latitude-e6440-ccert-201306-13687 ./alc292-dell-latitude-e6440-ccert-201306-13688 ./alc292-dell-latitude-e6540-ccert-201306-13679 ./alc292-dell-latitude-e7240-ccert-201304-13407 ./alc292-dell-latitude-e7440-ccert-201304-13408 ./alc3223-dell-inspiron-3531-ccert-201403-14892 ./alc3223-dell-inspiron-3531-ccert-201404-14984 ./alc3226-dell-latitude-12-rugged-extreme--7204--ccert-201402-14663 ./alc3226-dell-latitude-14-rugged-extreme--7404--ccert-201402-14666 ./alc3226-dell-latitude-14-rugged-extreme--7404--ccert-201402-14667 ./alc3226-dell-precision-m2800-ccert-201404-14985 ./alc3226-dell-precision-m2800-ccert-201404-14986 ./alc3226-dell-precision-m2800-ccert-201404-14987 ./alc3234-dell-inspiron-11---3147-ccert-201403-14888 ./alc3234-dell-inspiron-11---3147-ccert-201403-14889 ./alc3234-dell-inspiron-3441-ccert-201403-14840 ./alc3234-dell-inspiron-3441-ccert-201403-14841 ./alc3234-dell-inspiron-3442-ccert-201402-14674 ./alc3234-dell-inspiron-3442-ccert-201402-14675 ./alc3234-dell-inspiron-3541-ccert-201403-14860 ./alc3234-dell-inspiron-3542-ccert-201402-14683 ./alc3234-dell-inspiron-3542-ccert-201402-14684 ./alc3234-dell-inspiron-5442-ccert-201404-15002 ./alc3234-dell-inspiron-5442-ccert-201404-15016 ./alc3234-dell-inspiron-5445-ccert-201405-15050 ./alc3234-dell-inspiron-5445-ccert-201405-15051 ./alc3234-dell-inspiron-5447-ccert-201401-14528 ./alc3234-dell-inspiron-5542-ccert-201404-15003 ./alc3234-dell-inspiron-5542-ccert-201404-15004 ./alc3234-dell-inspiron-5545-ccert-201405-15052 ./alc3234-dell-inspiron-5545-ccert-201405-15053 ./alc3234-dell-inspiron-5547-ccert-201401-14530 ./alc3234-dell-inspiron-5547-ccert-201401-14542 ./alc3234-dell-inspiron-5748-ccert-201402-14681 ./alc3234-dell-inspiron-5748-ccert-201402-14682 ./alc3234-dell-inspiron-7347-ccert-201406-15234 ./alc3234-dell-inspiron-7347-ccert-201406-15257 ./alc3234-dell-inspiron-7447-ccert-201406-15233 ./alc3234-dell-inspiron-7447-ccert-201406-15256 ./alc3234-dell-optiplex-3020m-ccert-201405-15030 ./alc3234-dell-optiplex-9020m-ccert-201405-15029 ./alc3234-dell-vostro-3445-ccert-201403-14842 ./alc3234-dell-vostro-3446-ccert-201402-14676 ./alc3234-dell-vostro-3446-ccert-201402-14677 ./alc3234-dell-vostro-3546-ccert-201404-14996 ./alc3234-dell-vostro-3546-ccert-201404-14997 ./alc3234-dell-vostro-3546-ccert-201404-14998 ./alc3661-dell-inspiron-20-model-3048-ccert-201401-14493 ./alc3661-dell-inspiron-20-model-3048-ccert-201401-14508 ./alc3661-dell-inspiron-23-model-5348-ccert-201312-14427 ./alc3661-dell-inspiron-23-model-5348-ccert-201312-14428 ./alc3661-dell-optiplex-3030-aio-ccert-201401-14498 ./alc3661-dell-optiplex-3030-aio-ccert-201401-14499 ./alc3661-dell-optiplex-9030-aio-ccert-201312-14425 ./alc3661-dell-optiplex-9030-aio-ccert-201312-14426 ./alc3661-dell-vostro-20-3010-ccert-201401-14509 ./alc3661-dell-vostro-20-3015-ccert-201402-14810 ./alc3661-dell-vostro-20-3015-ccert-201403-14826 ./alc3661-dell-vostro-20-model-3010-ccert-201401-14510 ./alc668-dell-inspiron-2350-ccert-201305-13669 ./alc668-dell-inspiron-2350-ccert-201305-13670 ./alc668-dell-xps13-9333-ccert-201309-14237 ./id-2c06-dell-latitude-e6540-ccert-201302-12845
From a UI point of view, there are two aspects to this: 1. We need to show something when a device is plugged in for the first time. A system modal dialog, provided by GNOME Shell, might be the best thing here: it is obvious and needs to be explicitly dismissed. This will prevent a device not working because it hasn't been configured. 2. There should be a place where you can change the type of device, probably in the sound settings. I think we have this already - this is just to note that it needs to be there in order to allow errors to be corrected, if they're made.
As I've been advising somebody who's interested in getting this fixed upstream, here are a few comments: 1) pa-backend.[ch] http://bazaar.launchpad.net/~unity-settings-daemon-team/unity-settings-daemon/trunk/view/head:/plugins/media-keys/what-did-you-plug-in/pa-backend.c That does 2 things, monitor card changes (we know how to do that in the gvc git submodule), and check whether the hardware mixer needs to ask the type of accessory plugged in, by poking ALSA directly. This should be implemented in PulseAudio directly, and would allow us to avoid another dependency. http://bazaar.launchpad.net/~unity-settings-daemon-team/unity-settings-daemon/trunk/view/head:/plugins/media-keys/what-did-you-plug-in/pa-backend.c#L45 2) dialog-window.[ch] We wouldn't implement this in gnome-settings-daemon directly, we don't want g-s-d to have "UI". This would be implemented through a gnome-shell OSD, similarly to "showOSD" in https://git.gnome.org/browse/gnome-shell/tree/js/ui/shellDBus.js So, in short: - need to add PulseAudio support for tagging the cards with their capabilities - need to export that metadata in the "gvc" git submodule - add OSD D-Bus support in gnome-shell - wire all this in gnome-settings-daemon's media-keys plugin
Created attachment 318325 [details] [review] media-keys: "What did you plug in" support rev 4014 unity-settings-daemon revision 4014 http://bazaar.launchpad.net/~unity-settings-daemon-team/unity-settings-daemon/trunk/revision/4014
Created attachment 318326 [details] [review] media-keys: "What did you plug in" support 4028 unity-settings-daemon revision 4028 http://bazaar.launchpad.net/~unity-settings-daemon-team/unity-settings-daemon/trunk/revision/4028
Created attachment 318327 [details] [review] media-keys: "What did you plug in" support 4121 unity-settings-daemon revision 4121 http://bazaar.launchpad.net/~unity-settings-daemon-team/unity-settings-daemon/trunk/revision/4121
Created attachment 318328 [details] [review] media-keys: "What did you plug in" support, compilation warning fixes
Created attachment 318329 [details] [review] media-keys: "What did you plug in" support, build fixes
Created attachment 318331 [details] [review] media-keys: "What did you plug in support" 4014 unity-settings-daemon revision 4014 http://bazaar.launchpad.net/~unity-settings-daemon-team/unity-settings-daemon/trunk/revision/4014
This is an untested rebase of the unity-settings-daemon patches for gnome-settings-daemon. This is obviously unsuitable for merging, and will be squashed and fixed before applying it.
With the 4121 patch, I think we can skip the ALSA part entirely. I believe it was only needed to separate headphone-mic mode from normal mic mode, and since PA 6.0 we can do that with PA.
(In reply to David Henningsson from comment #13) > With the 4121 patch, I think we can skip the ALSA part entirely. I believe > it was only needed to separate headphone-mic mode from normal mic mode, and > since PA 6.0 we can do that with PA. You mean that if we use PA 6, and with the patch rev 4121, we can remove the verify_alsa_card() call in the original patch?
(In reply to David Henningsson from comment #13) > With the 4121 patch, I think we can skip the ALSA part entirely. I believe > it was only needed to separate headphone-mic mode from normal mic mode, and > since PA 6.0 we can do that with PA. On second thought, while that particular thing is indeed fixed with PA 6+, there is also another thing we use the alsa for - figuring out whether the headset mic has individual detection for input and output, or not. I e, to check whether we have a "Headset Mic Jack" or a "Headset Mic Phantom Jack". We could potentially check the availability of the analog-input-headset-mic port instead though...needs more thinking.
Created attachment 318745 [details] [review] media-keys: "What did you plug in" support rev 4014 unity-settings-daemon revision 4014 http://bazaar.launchpad.net/~unity-settings-daemon-team/unity-settings-daemon/trunk/revision/4014
Created attachment 318746 [details] [review] media-keys: "What did you plug in" support rev 4028 unity-settings-daemon revision 4028 http://bazaar.launchpad.net/~unity-settings-daemon-team/unity-settings-daemon/trunk/revision/4028
Created attachment 318747 [details] [review] media-keys: "What did you plug in" support rev 4121 unity-settings-daemon revision 4121 http://bazaar.launchpad.net/~unity-settings-daemon-team/unity-settings-daemon/trunk/revision/4121
Created attachment 318748 [details] [review] media-keys: "What did you plug in" support, compilation warning fixes
Created attachment 318749 [details] [review] media-keys: "What did you plug in" support, build fixes
Created attachment 318750 [details] [review] media-keys: "What did you plug in" support, launch g-c-c
Created attachment 318751 [details] [review] gvc: "What did you plug in support" rev 4014 unity-settings-daemon revision 4014 http://bazaar.launchpad.net/~unity-settings-daemon-team/unity-settings-daemon/trunk/revision/4014
The UI has been designed, removing ui-review.
Created attachment 318812 [details] [review] gvc: Add "what did you plug in" support API Add "audio-device-selection-needed" which will be emitted when a headphones, headset or microphone is plugged into a jack socket that cannot detect which type it was. Once the user of libgnome-volume-control has asked the user which type of device this was, they can call gvc_mixer_control_set_headset_port() to switch the ports for that configuration. Based on the original code by David Henningsson <david.henningsson@canonical.com> for the unity-settings-daemon
Created attachment 318813 [details] [review] build: Require ALSA and detect it on Linux systems This will be used to support audio device selection.
Created attachment 318814 [details] [review] media-keys: Use new gvc API for audio device detection
David, can you comment on the API added in attachment 318812 [details] [review]? I didn't get the chance to test it yet, but it should be the same functionality as your pa-backend.[ch], but without the need to hit PA or ALSA directly for the API users (and minimal g-s-d changes in the future). This shared API would also allow you to rebase your unity-settings-daemon support on a single upstream source.
Created attachment 318815 [details] [review] media-keys: Use new gvc API for audio device detection
Created attachment 318816 [details] [review] media-keys: Use new gvc API for audio device detection
Created attachment 318817 [details] [review] gvc: Add "what did you plug in" support API Add "audio-device-selection-needed" which will be emitted when a headphones, headset or microphone is plugged into a jack socket that cannot detect which type it was. Once the user of libgnome-volume-control has asked the user which type of device this was, they can call gvc_mixer_control_set_headset_port() to switch the ports for that configuration. Based on the original code by David Henningsson <david.henningsson@canonical.com> for the unity-settings-daemon
And fixed the crashers now. This just needs the D-Bus API in gnome-shell and squashing before merging.
Comment on attachment 318817 [details] [review] gvc: Add "what did you plug in" support API Ok, so I had a look at this, and nothing popped out as being immediately wrong or misdesigned. I would probably add some card index parameter to gvc_mixer_control_set_headset_port for the purpose of being future proof - in theory (but hardly in practice) there could be more than one card that has this functionality. Besides, the card index is already sent in the AUDIO_DEVICE_SELECTION_NEEDED signal. A lot of code is compiled out if we don't HAVE_ALSA, and I think at least some of the code - e g gvc_mixer_control_set_headset_port - could stay in as it does not use the ALSA API directly.
(In reply to David Henningsson from comment #32) > Comment on attachment 318817 [details] [review] [review] > gvc: Add "what did you plug in" support API > > Ok, so I had a look at this, and nothing popped out as being immediately > wrong or misdesigned. I would probably add some card index parameter to > gvc_mixer_control_set_headset_port for the purpose of being future proof - > in theory (but hardly in practice) there could be more than one card that > has this functionality. Besides, the card index is already sent in the > AUDIO_DEVICE_SELECTION_NEEDED signal. I'll do that and test before merging that part of the code. > A lot of code is compiled out if we don't HAVE_ALSA, and I think at least > some of the code - e g gvc_mixer_control_set_headset_port - could stay in as > it does not use the ALSA API directly. I kept it disabled if ALSA wasn't available, because I felt it was fairly useless without the detection code, making it easier to remove.
Created attachment 318855 [details] [review] gvc: Add "what did you plug in" support API Add "audio-device-selection-needed" which will be emitted when a headphones, headset or microphone is plugged into a jack socket that cannot detect which type it was. Once the user of libgnome-volume-control has asked the user which type of device this was, they can call gvc_mixer_control_set_headset_port() to switch the ports for that configuration. Note that gvc_mixer_control_set_headset_port() supports passing the card ID, but the detection code only supports a single such device. When we find hardware that can support > 1 such device, we can test and implement support without breaking the API. Based on the original code by David Henningsson <david.henningsson@canonical.com> for the unity-settings-daemon
Created attachment 318856 [details] [review] media-keys: Use new gvc API for audio device detection
Comment on attachment 318855 [details] [review] gvc: Add "what did you plug in" support API Pushed the libgnome-volume-control patch to master. Attachment 318855 [details] pushed as f3f6812 - gvc: Add "what did you plug in" support API
Created attachment 321080 [details] [review] media-keys: Use new gvc and g-s APIs for audio device selection This adds a dependency on ALSA. -- This seems to work but I don't have the hardware to actually know if it's all working on the stack below us.
Pushed with an expanded commit message. I think we're done here. Attachment 321080 [details] pushed as 332836c - media-keys: Use new gvc and g-s APIs for audio device selection