After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 755062 - Ask which type of sound device got plugged in
Ask which type of sound device got plugged in
Status: RESOLVED FIXED
Product: gnome-settings-daemon
Classification: Core
Component: general
3.17.x
Other Linux
: Normal normal
: ---
Assigned To: gnome-settings-daemon-maint
gnome-settings-daemon-maint
Depends on: 760284
Blocks:
 
 
Reported: 2015-09-15 13:28 UTC by Bastien Nocera
Modified: 2016-02-16 16:42 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
jack_detect_windows.png (110.07 KB, image/png)
2015-09-15 13:28 UTC, Bastien Nocera
  Details
media-keys: "What did you plug in" support rev 4014 (22.16 KB, patch)
2016-01-06 14:29 UTC, Bastien Nocera
none Details | Review
media-keys: "What did you plug in" support 4028 (3.49 KB, patch)
2016-01-06 14:29 UTC, Bastien Nocera
none Details | Review
media-keys: "What did you plug in" support 4121 (3.43 KB, patch)
2016-01-06 14:29 UTC, Bastien Nocera
none Details | Review
media-keys: "What did you plug in" support, compilation warning fixes (2.71 KB, patch)
2016-01-06 14:30 UTC, Bastien Nocera
none Details | Review
media-keys: "What did you plug in" support, build fixes (1.30 KB, patch)
2016-01-06 14:30 UTC, Bastien Nocera
none Details | Review
media-keys: "What did you plug in support" 4014 (1.91 KB, patch)
2016-01-06 14:31 UTC, Bastien Nocera
none Details | Review
media-keys: "What did you plug in" support rev 4014 (22.16 KB, patch)
2016-01-11 15:25 UTC, Bastien Nocera
none Details | Review
media-keys: "What did you plug in" support rev 4028 (3.49 KB, patch)
2016-01-11 15:26 UTC, Bastien Nocera
none Details | Review
media-keys: "What did you plug in" support rev 4121 (3.44 KB, patch)
2016-01-11 15:26 UTC, Bastien Nocera
none Details | Review
media-keys: "What did you plug in" support, compilation warning fixes (2.71 KB, patch)
2016-01-11 15:26 UTC, Bastien Nocera
none Details | Review
media-keys: "What did you plug in" support, build fixes (1.30 KB, patch)
2016-01-11 15:26 UTC, Bastien Nocera
none Details | Review
media-keys: "What did you plug in" support, launch g-c-c (1.38 KB, patch)
2016-01-11 15:26 UTC, Bastien Nocera
none Details | Review
gvc: "What did you plug in support" rev 4014 (1.91 KB, patch)
2016-01-11 15:26 UTC, Bastien Nocera
none Details | Review
gvc: Add "what did you plug in" support API (16.49 KB, patch)
2016-01-11 18:13 UTC, Bastien Nocera
none Details | Review
build: Require ALSA and detect it on Linux systems (2.52 KB, patch)
2016-01-11 18:13 UTC, Bastien Nocera
none Details | Review
media-keys: Use new gvc API for audio device detection (14.00 KB, patch)
2016-01-11 18:13 UTC, Bastien Nocera
none Details | Review
media-keys: Use new gvc API for audio device detection (14.00 KB, patch)
2016-01-11 18:24 UTC, Bastien Nocera
none Details | Review
media-keys: Use new gvc API for audio device detection (15.36 KB, patch)
2016-01-11 18:29 UTC, Bastien Nocera
none Details | Review
gvc: Add "what did you plug in" support API (16.42 KB, patch)
2016-01-11 18:40 UTC, Bastien Nocera
none Details | Review
gvc: Add "what did you plug in" support API (16.97 KB, patch)
2016-01-12 12:21 UTC, Bastien Nocera
committed Details | Review
media-keys: Use new gvc API for audio device detection (15.79 KB, patch)
2016-01-12 12:22 UTC, Bastien Nocera
none Details | Review
media-keys: Use new gvc and g-s APIs for audio device selection (10.85 KB, patch)
2016-02-13 19:28 UTC, Rui Matos
committed Details | Review

Description Bastien Nocera 2015-09-15 13:28:03 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).
Comment 1 David Henningsson 2015-09-15 13:39:01 UTC
@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).
Comment 2 Bastien Nocera 2015-11-17 10:03:05 UTC
What hardware do we need to test this?
Comment 3 David Henningsson 2015-11-17 10:13:13 UTC
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
Comment 4 Allan Day 2015-11-17 16:15:05 UTC
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.
Comment 5 Bastien Nocera 2015-11-19 14:54:27 UTC
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
Comment 6 Bastien Nocera 2016-01-06 14:29:41 UTC
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
Comment 7 Bastien Nocera 2016-01-06 14:29:49 UTC
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
Comment 8 Bastien Nocera 2016-01-06 14:29:55 UTC
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
Comment 9 Bastien Nocera 2016-01-06 14:30:01 UTC
Created attachment 318328 [details] [review]
media-keys: "What did you plug in" support, compilation warning fixes
Comment 10 Bastien Nocera 2016-01-06 14:30:08 UTC
Created attachment 318329 [details] [review]
media-keys: "What did you plug in" support, build fixes
Comment 11 Bastien Nocera 2016-01-06 14:31:07 UTC
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
Comment 12 Bastien Nocera 2016-01-06 14:32:26 UTC
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.
Comment 13 David Henningsson 2016-01-08 10:35:13 UTC
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.
Comment 14 Bastien Nocera 2016-01-09 15:00:55 UTC
(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?
Comment 15 David Henningsson 2016-01-09 15:49:23 UTC
(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.
Comment 16 Bastien Nocera 2016-01-11 15:25:45 UTC
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
Comment 17 Bastien Nocera 2016-01-11 15:26:01 UTC
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
Comment 18 Bastien Nocera 2016-01-11 15:26:09 UTC
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
Comment 19 Bastien Nocera 2016-01-11 15:26:16 UTC
Created attachment 318748 [details] [review]
media-keys: "What did you plug in" support, compilation warning fixes
Comment 20 Bastien Nocera 2016-01-11 15:26:22 UTC
Created attachment 318749 [details] [review]
media-keys: "What did you plug in" support, build fixes
Comment 21 Bastien Nocera 2016-01-11 15:26:29 UTC
Created attachment 318750 [details] [review]
media-keys: "What did you plug in" support, launch g-c-c
Comment 22 Bastien Nocera 2016-01-11 15:26:54 UTC
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
Comment 23 Bastien Nocera 2016-01-11 15:41:45 UTC
The UI has been designed, removing ui-review.
Comment 24 Bastien Nocera 2016-01-11 18:13:05 UTC
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
Comment 25 Bastien Nocera 2016-01-11 18:13:39 UTC
Created attachment 318813 [details] [review]
build: Require ALSA and detect it on Linux systems

This will be used to support audio device selection.
Comment 26 Bastien Nocera 2016-01-11 18:13:45 UTC
Created attachment 318814 [details] [review]
media-keys: Use new gvc API for audio device detection
Comment 27 Bastien Nocera 2016-01-11 18:15:43 UTC
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.
Comment 28 Bastien Nocera 2016-01-11 18:24:54 UTC
Created attachment 318815 [details] [review]
media-keys: Use new gvc API for audio device detection
Comment 29 Bastien Nocera 2016-01-11 18:29:02 UTC
Created attachment 318816 [details] [review]
media-keys: Use new gvc API for audio device detection
Comment 30 Bastien Nocera 2016-01-11 18:40:22 UTC
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
Comment 31 Bastien Nocera 2016-01-11 18:41:27 UTC
And fixed the crashers now. This just needs the D-Bus API in gnome-shell and squashing before merging.
Comment 32 David Henningsson 2016-01-12 12:09:00 UTC
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.
Comment 33 Bastien Nocera 2016-01-12 12:12:28 UTC
(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.
Comment 34 Bastien Nocera 2016-01-12 12:21:26 UTC
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
Comment 35 Bastien Nocera 2016-01-12 12:22:08 UTC
Created attachment 318856 [details] [review]
media-keys: Use new gvc API for audio device detection
Comment 36 Bastien Nocera 2016-01-17 20:41:33 UTC
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
Comment 37 Rui Matos 2016-02-13 19:28:36 UTC
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.
Comment 38 Rui Matos 2016-02-16 16:42:20 UTC
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