= alsa-dispatcher(8) :doctype: manpage :revdate: {sys:date "+%Y-%m-%d %H:%M:%S"} == NAME alsa-dispatcher - ALSA priority dispatcher for occasional playback endpoints. == SYNOPSIS *alsa-dispatcher* == DESCRIPTION *alsa-dispatcher* is an ALSA utility that handles dispatch of audio playback via a priority list of possible endpoints. The dispatch logic works through the list trying to open each ALSA PCM device in order until one succeeds, and thereafter *alsa-dispatcher* simply channels the playback audio stream from its standard input to the successfully opened PCM playback device. The setup for using *alsa-dispatcher* includes two configuration aspects: 1. The ALSA configuration needs to be augmented with a _pcm_ block that directs playback to *alsa-dispatcher* and capture from, say, _plughw_ (i.e., the primary sound card). 2. The priority list of possible endpoints for *alsa-dispatcher* is a text file named _$HOME/.alsa-dispatcher_. === ALSA configuration (e.g. $HOME/.asoundrc) The ALSA configuration collection needs to include a declaration for *alsa-dispatcher* as an ALSA PCM by means of a short declaration in the user's _$HOME/.asoundrc_ file or system-wide (e.g _/etc/asoundrc.conf_ or _/etc/alsa/conf.d/51-alsa-dispatcher.conf_) The following is an example _$HOME/.asoundrc_. ---- pcm.!default dispatch pcm.dispatch { type asym playback { pcm { type plug slave { pcm "file:|exec /usr/bin/alsa-dispatcher" format S16_LE; channels 2; rate 48000; } } } capture plughw } ---- The first line in the example asserts that "dispatch" is the default PCM. I.e. that playback directed to "default" should be passed on to "dispatch". The rest of the example declares the "dispatch" PCM to be an "asym" that has the playback stream directed via a pipe to the command _/usr/bin/alsa-dispatcher_ (which is where *alsa-dispatcher* is installed in this example), and further it has the capture stream sourced from _plughw_ (i.e. the default sound card). Note that the playback PCM explicitly declares the stream characteristics (format, channels and rate) as used by *alsa-dispatcher*. === About $HOME/.alsa-dispatcher The endpoints are enumerated for *alsa-dispatcher* in a text file _$HOME/.alsa-dispatcher_ with one line for each PCM device. The line contains PCM name and optionally setting variations for that device, in the form of _key=value_. Currently only _latency_ may be varied. Blank lines and lines starting with "#" are comments. The following is an illustration example. ---- bt usb plughw ---- The example _$HOME/.alsa-dispatcher_ nominates _bt_ as the first ALSA PCM to try, then the _usb_ device and the _plughw_ as the third and last option. It's an imagined setup with a bluetooth device _bt_ that should have priority when in use, next a USB sound card _usb_ as secondary option when in use, and third the default sound card _plughw_. Thus, *alsa-dispatcher* will try to direct playback to _bt_ first. If that is not in use *alsa-dispatcher* tries to direct playback to _usb_ and if the is not in use either, then *alsa-dispatcher* directs playback to _plughw_ (i.e. the default sound card). == NOTES *alsa-dispatcher* keeps channeling playback to a selected endpoint as long as that remains available. If the endpoint goes away (or the *alsa-dispatcher* program is killed) that channeling is interrupted. The original sound source (eg a browser) may then establish a new playback sink, which would cause a new *alsa-dispatcher* to run through the priority list again to pick the first option available in the then current audio context. The program is an embedded _newlisp_ script of manageable size that links up with _libasound.so_ for ALSA API actions. == SEE ALSO *newlisp* == AUTHOR Ralph Ronnquist