Line-in jack sense with C/C++ in Ubuntu

2020-04-09 14:33发布

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.

1条回答
爱情/是我丢掉的垃圾
2楼-- · 2020-04-09 15:07

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 
查看更多
登录 后发表回答