Sometimes my laptop gets to a state in which sound works through the built-in speakers, but not through the headphone jack. Possibly my solution is too brutal, but it works -Â restarting the whole sound subsystem. I guess that it may come handy in other situation: the ability to restart a subsystem instead of rebooting the machine, is always an advantage.
The rationale is simply reloading the kernel module that acts as a driver to our sound hardware. Reloading isn't easy, as:
- Kernel modules use this module.
- User processes use this module.
Every time when I try to sit and study, I find something better to do. This time it was playing with Avahi and some avahi clients such as pidgin, amarok, pulseaudio.
What is Avahi?
A free zeroconf implementation which is very common on Linux distros, just as Bonjour is Apple's zeroconf implementation. AKA multicast DNS (mDNS), and is probably similar to the Microsoft-backed UPnP.
Long story short: it allows discovering and resolving the available services on the LAN (if they're zeroconf-aware, of course)
How do I use Avahi?
- Discovering: If the avahi daemon is installed and running, the magical command avahi-browse -a (might require the avahi-utils package) would query and display all the available services.
- Resolving: the following weird hosts line in /etc/nsswitch.conf enables resolving through avahi (usually with the .local suffix, i.e. ping mymachine.local):
hosts:Â Â Â Â Â Â Â Â Â files dns mdns4_minimal [NOTFOUND=return]
Software using Avahi out of the box:
- Pidgin: simply add a new Bonjour account, and you'll be able to instantly talk to your LAN-neighbors.
- CUPS or other printer config frontends: find zeroconf-supporting printers on the LAN.
- Amarok v2: automagically finds all DAAP-shares on the LAN (iTunes, for example). The bad news is: iTunes v7 and newer weren't yet reverse-engineered, so amarok cannot login to the most popular DAAP servers. Apple, why won't you give us a hand?
- Pulseaudio: using the paprefs program, you can choose to share your sound devices and become zeroconf-discoverable. This means that people running the padevchooser program can find your sound card and redirect audio to/from yours.
- It seems to require a wide bandwidth (couldn't find an option to lower the sound quality)
- I've experienced some bugs which required restarting pulseaudio and other voodoo, in order to make things work.