View Single Post
thp's Avatar
Posts: 1,391 | Thanked: 4,272 times | Joined on Sep 2007 @ Vienna, Austria
#56
Originally Posted by unkno View Post
I have a question...if headphoned is kept running in the background, won't it eat up CPU cycles? If it does eat a noticeable amount, is it possible to code it in such a way that it will only run when it detects the headphone is connected and also end the task after pausing when headphones are removed.
That's actually how it works: headphoned installs a I/O watch that gets executed every time the state file changes (which is only when the headphones get plugged/unplugged). After that, it notifies all known media players and then returns to the main loop which again is waiting for I/O (by blocking on the state file). If you use "ps", you should see that headphoned is sleeping ("S") most of the time.

The only thing that headphoned uses constantly is a bit of your main memory.

See http://git.maemo.org/git/headphoned/...c/headphoned.c
 

The Following 4 Users Say Thank You to thp For This Useful Post: