• Uncategorized

About c++ : Line-in-jack-sense-with-CC-in-Ubuntu

Question Detail

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.


Question Answer

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 

You may also like...

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.