Re: [Call for testing] sound: Implement /dev/dsp as a router device

From: Jakob Alvermark <jakob_at_alvermark.net>
Date: Mon, 07 Apr 2025 11:38:12 UTC
Hi,


This is cool.

I did some quick testing.

Playing some audio and plugging in my USB-C headset the audio switches 
over to the headset and continues playing in the headset.

However, unplugging the headset does not seem to work fully. If I play 
something in chromium (a Youtube video for example), it stops.

I tried playing an mp3 file using audio/mpg123, and when unplugging the 
headset I get this error:

[src/libout123/libout123.c:out123_play():746] error: Error in writing 
audio, wrote only -1 of 2304 (Invalid argument?)!
main: [src/mpg123.c:play_frame():857] error: Deep trouble! Cannot flush 
to my output anymore!

On the other hand, multimedia/mplayer does work, switching seamlessly 
between the laptop speaker and headset.


Jakob

On 2025-04-06 21:08, Christos Margiolis wrote:
> I've been working on a patch [1] to re-implement /dev/dsp as a
> router/virtual device. The commit message in the review explains all the
> high-level details and reasons behind the patch. This is the first of a
> series of patches I'm working on.
>
> For regular users, the main functional difference is that with this
> patch, /dev/dsp is an actual router device (like when using
> virtual_oss), which means that we have hot-swapping (i.e., changing the
> default device and routing audio to it during IO without needing to
> close and re-open /dev/dsp) built into sound(4).
>
> Feel free to test the patch and please let me know if there's anything
> that breaks or could be improved. You can play around with it just by
> recording/playing audio as you always do, try some hot-swaps,
> hot-(un)plugs, and anything that can stress test it. Just make sure you
> open /dev/dsp, which should be the default for most applications anyway.
>
> Christos
>
> [1] https://reviews.freebsd.org/D49216
>