Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 9 Apr 2025 11:43:43 +0200
From:      "Mathias M." <mma@darktemple.ch>
To:        freebsd-multimedia@freebsd.org
Subject:   Re: [Call for testing] sound: Implement /dev/dsp as a router device
Message-ID:  <Z_ZBTyCiGGYvsyF6@apollonios>
In-Reply-To: <7f21cd55-5bb7-470f-88ae-c259710460bb@alvermark.net>
References:  <l2cfedicapbvj374ayetumvgwef5tyxwqy6kj6bapaprzkkxvt@edzltnq3km3a> <cac21f1c-997d-484d-8609-ed3d5ec2d8f4@alvermark.net> <uebrosibqnq5qbw7htd7grudl47cztc5va5dj7mitx537uv2eb@tx74cmc2y7xw> <7f21cd55-5bb7-470f-88ae-c259710460bb@alvermark.net>

index | next in thread | previous in thread | raw e-mail

[-- Attachment #1 --]
Hey there,

I just want to interject that chrome and Firefox have different
implementations on how they use sound devices.
The also offer different information to websites that output sound.

I don't know the exact details. But to use the VOIP phone at work, I
HAVE TO use chrome so that I can select a different outputs for the
ringtone (my speaker) and speech (my headset). According to the
developer, the web application can't even detect devices in Firefox.

So I would not waste too much time in as to why those two handle sound
things differently and concentrate on software that explicitly uses
/dev/dsp.

Regards,
Mathias

On Tue, Apr 08, 2025 at 06:21:55PM +0200, Jakob Alvermark wrote:
> On 2025-04-08 00:23, Christos Margiolis wrote:
> > Hello Jakob,
> >
> > Jakob Alvermark wrote:
> > > 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.
> > See what I write below, it could be a similar issue. Also, does this
> > happen on other browsers, say, firefox?
>
> Interestingly, with firefox, the audio does not switch over to the headset.
>
> I tried this:
>
> - Start playing audio in firefox and start playing some audio in chromium.
>
> - Plug in USB-C headphones.
>
> - The audio from firefox still plays through the laptop speaker, but the
> chromium audio switches over to the headphones.
>
> - Unplug headphones.
>
> - Firefox audio still plays through laptop speakers as if nothing happened,
> chromium audio 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!
> > I am not familiar with audio/mpg123, but the error message suggests that
> > the program exits upon a write() error. That is not really an issue of
> > sound(4), but that audio/mpg123 exits on the first write() error. mpv
> > for example, or mplayer as you said, do not have this problem.
> >
> > My first guess would be that the error is generated during the
> > hot-unpluging, because in the time window between the device detach and
> > the switch to the new default device, write() will have failed since the
> > device stopped doing IO at this point. That is not wrong behavior on
> > sound(4)'s side though.
> >
> > > On the other hand, multimedia/mplayer does work, switching seamlessly
> > > between the laptop speaker and headset.
> > Just to make sure, the switching is successful even during IO, right?
> Yes, with mplayer, switching works fine, both plugging and unplugging, while
> playing an mp3 file.
> > > 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
> > Christos
>

--
Ferengi Rule of Acquisition #58:
There is no substitute for success.
-- The Ferengi Rules of Acquisition (DS9 reference book)

[-- Attachment #2 --]
-----BEGIN PGP SIGNATURE-----

iQIzBAABCgAdFiEEum0Wt+j5KRb8jmV5YyszEUJSlY0FAmf2QU4ACgkQYyszEUJS
lY2W8BAAv8RyhPyhh0cps2EorIrWehfBHqvK4OGhPt71RaFVAnMb8BLkVO2znvOO
NKmCND1+DFdbV0HV73vx+lZ3YZRfEjQ458rO9dhTjSfBgLjzcI2KKrRiY4ObTkO3
EIVdFOoO8f2M7vQiL0PXd2oJrJZMhzHWWi8/VVpexIztY2U6lQV35tCvd8qoVoaG
qL9B6OmSaLM34t66QUnj043n9DFonPkJJ9Zu4uiJr1eK0GxT/bEimabcliYZgHIT
8oYQMZ7xH/OsRIym30ptYJLo4TKeitdtJ/l3N41dutsEF9hIEJM4YaXj7FHj+JoP
xQ4hag0uoKGMHdvKwrFgpwSGzMppdqjtTxFggmaKwqIe8gIU9X10HFa5cHlUAoa2
xGhgb5JDyuL/tYB1jnQ1JmknZpO6i4ip+Q2P3d0nJJKlaO4dsYXEh0Y6A3xuXeHv
5RQ+ggzHeHMa4AryF+fux3p6+L7psMTybayQM9FDn4j5BmrSWNbXf1O/4WWq10NF
Mazyf0PaC0nAkqQRZ8ic++l1zqNBhiUY5F1wyeg5L1soE0XWRQKPbZ5LYXyRF9+4
x/PvA3xLWKfXVSeNrYhKQpY/D7KYgLsDsIQLuNJNPN9F5nl2GKZxM846uKO9hjHq
XZgeL4pNbOiK86m1yxGhogEF8VkXenNYV0Uj1gSm7NMFZjBJK/s=
=NA96
-----END PGP SIGNATURE-----
help

Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Z_ZBTyCiGGYvsyF6>