On 29/08/19(Thu) 10:52, Alexandre Ratchov wrote:
> The diff below allows to specifiy "an alternate device" to use in case
> the audio device is disconnected. If so, programs continue playing
> using the other device.
> 
> For instance, if dmesg contains:
> 
>       audio0 at azalia0
>       audio1 at uaudio0
> 
> and /etc/rc.conf.local contains:
> 
>       sndiod_flags=-f rsnd/0 -F rsnd/1
> 
> then sndiod will try to use the usb device by default. If it's
> disconnected, programs continue using the internal one. Note that
> there's no way to detect that the usb device is reconnected;

Instead of doing a open/reopen dance in userland, which is inherently
racy, did you consider introducing a driver abstracting the various
audio(4) drivers attached?  I'm thinking of something like wsmux(4) for
audio.  This should allow us to transparently attach/detach usb audio
devices.

>                                                              the
> internal one will keep playing until all programs stop; then sndiod
> will retry the usb one again. To force sndiod to retry the usb one,
> send SIGHUP.

I'm not a fan of having such hotplug logic in userland because it is by
default racy and opens a can of worm for being able to configure how / 
when a driver becomes the default one.

> As we're at it, the same logic is applied to MIDI as well; it makes
> possible to swap instuments without restarting programs.
> 
> For all this to work, both audio devices must support the same rate
> (48kHz by default) and the same block size (now 10ms by default). This
> requires the block size calculation to be fixed in the audio(9) layer,
> so this diff is needed as well:

With the idea above you could attach all 'converted' audio drivers to
the mux ;)

Reply via email to