Sound defaults to external USB for me as per
https://www.openbsd.org/faq/faq13.html#usbaudio
$ dmesg | grep uaudio0
uaudio0 at uhub3 port 1 configuration 1 interface 3 "Creative
Technology Ltd Creative BT-W4" rev 2.00/28.38 addr 5
uaudio0: class v1, full-speed, sync, channels: 2 play, 1 rec, 3 ctls
audio1 at uaudio0
$ rcctl get sndiod flags
-f rsnd/0 -F rsnd/1
Pull the device and sound switches to notebook speakers.
Replug and SIGHUP sndiod to use USB again. Works great.
However, detach USB during explicit playback to it, e.g.
$ AUDIODEVICE=snd/1 ncspot
crashes sndiod(8) rather than playback just stopping instead of switching.
Using USB alone ('sndiod -f snd/1') and device defaults ('ncspot') does not
crash when unplugging during playback.
Minimal reproducer (DEBUG='-g3 -O0' build, otherwise backtrace is all ??):
$ doas obj/sndiod -d -f rsnd/0 -F rsnd/1 &
[1] 92393
$ aucat -i /dev/zero -f snd/1
[unplug]
snd1: switching to snd0
sock_close: not on list
snd/1: audio device gone, stopping
[1] + doas obj/sndiod -d -f rsnd/0 -F rsnd/1
Abort trap (core dumped)
$ doas egdb -q obj/sndiod /var/crash/sndiod/92393.core -batch -ex bt
[New process 575012]
Core was generated by `sndiod'.
Program terminated with signal SIGABRT, Aborted.
#0 kill () at /tmp/-:2
2 /tmp/-: No such file or directory.
#0 kill () at /tmp/-:2
#1 0xc8e16c0748c54a75 in ?? ()
#2 0x000005340e83dbce in panic () at /s/usr.bin/sndiod/utils.c:138
#3 0x000005340e839308 in sock_close (f=0x5340e842720 <slot_array>) at
/s/usr.bin/sndiod/sock.c:183
#4 0x000005340e838fe3 in sock_exit (arg=0x5340e842720 <slot_array>) at
/s/usr.bin/sndiod/sock.c:389
#5 0x000005340e829ff6 in dev_migrate (odev=0x536ddacb9c0) at
/s/usr.bin/sndiod/dev.c:1392
#6 0x000005340e8357c3 in dev_sio_hup (arg=0x536ddacb9c0) at
/s/usr.bin/sndiod/siofile.c:545
#7 0x000005340e8309d8 in file_process (f=0x5369435e420,
pfd=0x79a16362a238) at /s/usr.bin/sndiod/file.c:289
#8 0x000005340e831059 in file_poll () at /s/usr.bin/sndiod/file.c:433
#9 0x000005340e838341 in main (argc=0, argv=0x79a16362a778) at
/s/usr.bin/sndiod/sndiod.c:745