PulseAudio with jack detection

Jack detection in PulseAudio is now in Ubuntu 11.10. This means that PulseAudio will know whether you have plugged in your headphones, mic or HDMI cable, and be able to use that information. Most computers have automute already (i e, speakers mute when you plug in headphones), but this functionality is done entirely in the kernel. With PulseAudio now knowing about this, it can decide that your main volume control will adjust the headphones volume when you have headphones plugged in, and the speaker volume when you don’t.

HDMI adds one more twist to it. Due to hardware design, there are often several “false” ports accompanying the real one(s). And there is no way of knowing which one is right, except through jack detection. So you might see four different HDMI’s in the user interface, but only one is right, and with the jack detection, the right HDMI output will automatically be selected when you activate the HDMI device.
Speaking of the “Sound Preferences” user interface, I hope that we will have an improved user interface for Ubuntu 12.04, that can hide the HDMI devices that are unavailable.
(Also note that for NVidia and ATI cards, binary drivers are often needed to enable HDMI audio, as well as activating the display, through nvidia-settings or the “Displays” settings dialog.)

All of this won’t work for everyone from the start, as it will need support from the ALSA driver. However, for those who don’t have that support, things will not regress compared to the current handling. Hopefully I will be able to improve that situation for some of you in the 12.04 cycle.

Finally, a note on the upstream status of the patches needed for this functionality:

  • The PulseAudio patches will hopefully be merged into PulseAudio, once PulseAudio 1.0 is out. Until then, you can grab the latest patch set here.
  • A udev patch required to enable PulseAudio to read the input devices was rejected upstream.
  • A kernel patch used to identify HDMI input devices is pending upstream review/approval.
This entry was posted in PulseAudio and tagged , . Bookmark the permalink.

13 Responses to PulseAudio with jack detection

  1. Björgvin Ragnarsson says:

    Is it possible to backport this to Natty? There is a problem with the current method of jack detection on certain Dell Optiplex models.

    • I think it should be possible to backport to Natty, but I won’t put any effort into making a PPA or similar as Ubuntu 11.10 is soon to be released. However if you have a problem with a particular machine I’m not sure that this is the solution – please test your machine under Oneiric and if it does not work, file a bug using the “ubuntu-bug audio” command.

  2. htorque says:

    Can you be more specific: which packages and versions should bring the change? How can we easily test whether it works or not? I’m up-to-date on Oneiric (pa 1:0.99.3-0ubuntu2) but I’m not sure how to test that truly awesome feature. :-)

    • If you’re running an up-to-date version of Oneiric (with PA 1:0.99.3-0ubuntu2) that should be enough to test everything except HDMI. That is, if you’re on a typical laptop with headphones and internal speakers and your drivers support jack input devices: Open up the sound preferences dialog and go to the “output” tab. Then plug and unplug your headphones – if it’s working, your “Connector” should switch between “Analog Speakers” and “Analog Headphones” as you plug and unplug.

      • htorque says:

        Thanks for the reply!

        In that case you can add the ThinkPad T510 to the list of currently not working devices as the Connector only shows “Analog Output”.

      • PulseAudio 0.99.3-0ubuntu3 was released a few hours ago, which releases the HDMI part of it as well.

  3. HoellP says:

    Nice change in principal, but makes using my web cam a tad more uncomfortable…

    Additionally to my web cam i always have a headset plugged in, which i only use for gaming. Most of the time i want my web cam to be the input source. With this change in detection behavior, the input source is always the headset mic after booting and i have to switch to the web cam to use it. This setting is not saved and after the next log in, it switches back to the headset. I guess this is the jack detection working.

    Any chance, that this behavior gets more consistent in oneiric cycle?

    I can report it as a bug if that’ll help and you tell me against which package.

    Thanks for your work anyway, managing sound has come a long way the last few years.

    • Hmm. If your web cam is a separate sound card, the jack detection patches can’t be why it switches, as my policy module only switches between ports and profiles on the same card.
      If it’s an internal webcam that uses your internal sound card it could be, but then the kernel probably automutes anyway, even without jack detection patches. So in Oneiric, do report a bug using the “ubuntu-bug audio” terminal command.

      • HoellP says:

        Bug is reported, you can find my set up at https://bugs.launchpad.net/ubuntu/+source/alsa-driver/+bug/843780

        By the way, nothing is muted by default, the signal meter of the USB web cam’s shows clearly some input when i select it in the prefs. Also the correct jack of the Internal Audio device is set correctly. It is only the device itself which is not set correctly after reboot.
        Thanks for the directions.

  4. RapierTG says:

    Nice feature if you have jack sensing front panel. I have an old one without this feature. Now i cant make my headphones working. Is there any way of disabling it and make it old way?

    • If your hardware does not support jack sensing, everything should fall back to what it was before. We do have a new PulseAudio version, and a new kernel, so if things have regressed in Oneiric, the jack detection is unlikely to blame – but do file a bug against Oneiric if that is the case so we can catch it.

      • RapierTG says:

        My sound card is probably ok. The problem lies in old PC case with front panel which is not compatible with sensing.

        On windows it is the same by default, but i have option in my cards software to turn sensing off. Then i just have to mute speakers manually, but headphones are working.