4

This has probably been asked to death around here, but I could never get to a final solution (probably for good cause).

Anyway, is there any way in Ubuntu (I use Ubuntu 11.04 with kernel 2.6.38-8) to detect if there is a headphone plugged in? Specifically, I'm searching for C/C++ solutions to poll my ALSA device to detect if a headphone device has been plugged in.

Of all the threads I searched, this link deals only with Windows, and I couldn't figure out if this link provides a proper solution (there was no change whether the headphones were plugged in or not).

Ok, looong post, but I'd really appreciate the help.

Cheers,
Karthik.

Community
  • 1
  • 1
Karthik V
  • 1,033
  • 1
  • 14
  • 29

1 Answers1

3

The jack detection API is (here or here):

snd_jack_new — Create a new jack
snd_jack_set_parent — Set the parent device for a jack
snd_jack_report — Report the current status of a jack 
BЈовић
  • 62,405
  • 41
  • 173
  • 273
  • 1
    Thanks, I followed your link and from there started reading up on the ALSA API. I'll post any successes here, in case anybody else has the same requirements I do – Karthik V Jun 11 '11 at 11:17
  • I am working with same things to detect headphone jack but not able to access this link.Could you guys provide another link which shows jack detection API ? @BЈовић – raj123 Jun 28 '19 at 02:30
  • @raj123 Thanks. Fixed dead links. – BЈовић Jun 28 '19 at 06:20
  • I go through it,so its for kernel level API not application lever right?So using this I need to write kernel driver to detect jack right?@BЈовић – raj123 Jun 28 '19 at 17:29