USB sound devices with FreeBSD-CURRENT

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

USB sound devices with FreeBSD-CURRENT

grahamperrin
I'm confused about use of USB devices for audio (primarily with Firefox
and Chromium).

Re:
<https://forums.freebsd.org/threads/switching-dsp-devices-on-the-fly.69773/#post-419100>
under 'switching dsp-devices on-the-fly'

 > … hw.snd.default_unit to "0", which will automatically assign
 > hw.snd.default_unit to the newly-attached devices. …"

– so in sysctl.conf I experimented with:

hw.snd.default_unit="0"

– and after signing in (to KDE Plasma) I attach first the USB microphone
(Alctron USB700 Alctron USB700) then a USB headset (SteelSeries
SteelSeries Siberia 350).

virtual_oss and sndiod are enabled.

With this setup, as far as I can tell:

1. Chromium simply does not play AV content e.g.
<https://www.ted.com/talks/james_geary_metaphorically_speaking> – after
a click to play, there's a moment of visual motion but no playback

2. if Firefox media.cubeb.backend set to oss then behaviour is the same
as Chromium

3. if Firefox media.cubeb.backend is not set (audio backend defaults to
pulse-rust) then playback occurs through IDT 92HD81B1X (Analog) – not USB.

----

root@momh167-gjp4-8570p:~ # date ; uname -v
Sun Sep 13 08:25:39 BST 2020
FreeBSD 13.0-CURRENT #64 r365364: Sun Sep  6 01:38:18 BST 2020
root@momh167-gjp4-8570p:/usr/obj/usr/src/amd64.amd64/sys/GENERIC-NODEBUG
root@momh167-gjp4-8570p:~ # service virtual_oss start ; service sndiod
start ; service virtual_oss status ; service sndiod status ; cat
/dev/sndstat ; grep " -f /dev/" /usr/local/etc/rc.d/virtual_oss | grep
-v \# ; sysctl hw.snd.default_unit
Starting Virtual OSS config dsp ...hw.snd.basename_clone: 0 -> 0
  done
Starting sndiod.
virtual_oss is running as pid 5688.
sndiod is running as pid 5697.
Installed devices:
pcm0: <ATI R6xx (HDMI)> (play) default
pcm1: <IDT 92HD81B1X (Analog 2.0+HP/2.0)> (play/rec)
pcm2: <IDT 92HD81B1X (Analog)> (play/rec)
pcm3: <USB audio> (rec)
pcm4: <USB audio> (play/rec)
Installed devices from userspace:
dsp: <Virtual OSS> (play/rec)
   -f /dev/dsp0 \
hw.snd.default_unit: 0
root@momh167-gjp4-8570p:~ #

----

In addition, as far as I can tell:

4. if I remove then reconnect the two USB devices, the devices are no
longer driven

* neither device 'lights up'

* playback in Firefox (with oss) and Chromium is visible, but no longer
audible on any device

* playback in Firefox (with puse-rust) is visible, but no longer audible
on any device.

----

root@momh167-gjp4-8570p:~ # grep Alctron /var/log/messages
Sep 13 06:17:08 momh167-gjp4-8570p kernel: ugen0.7: <Alctron USB700
Alctron USB700> at usbus0 (disconnected)
Sep 13 06:19:07 momh167-gjp4-8570p kernel: ugen0.3: <Alctron USB700
Alctron USB700> at usbus0
Sep 13 06:19:07 momh167-gjp4-8570p kernel: uaudio0: <Alctron USB700
Alctron USB700, class 0/0, rev 1.10/1.00, addr 11> on usbus0
Sep 13 06:19:07 momh167-gjp4-8570p kernel: uhid1: <Alctron USB700
Alctron USB700, class 0/0, rev 1.10/1.00, addr 11> on usbus0
Sep 13 09:13:08 momh167-gjp4-8570p kernel: ugen0.5: <Alctron USB700
Alctron USB700> at usbus0
Sep 13 09:13:08 momh167-gjp4-8570p kernel: uaudio1: <Alctron USB700
Alctron USB700, class 0/0, rev 1.10/1.00, addr 4> on usbus0
Sep 13 09:13:08 momh167-gjp4-8570p kernel: uhid0: <Alctron USB700
Alctron USB700, class 0/0, rev 1.10/1.00, addr 4> on usbus0
Sep 13 09:48:51 momh167-gjp4-8570p kernel: ugen0.5: <Alctron USB700
Alctron USB700> at usbus0 (disconnected)
root@momh167-gjp4-8570p:~ # grep SteelSeries /var/log/messages
Sep 13 06:17:22 momh167-gjp4-8570p kernel: ugen0.6: <SteelSeries
SteelSeries Siberia 350> at usbus0 (disconnected)
Sep 13 06:17:51 momh167-gjp4-8570p kernel: ugen0.6: <SteelSeries
SteelSeries Siberia 350> at usbus0
Sep 13 06:17:51 momh167-gjp4-8570p kernel: uaudio0: <SteelSeries
SteelSeries Siberia 350, class 0/0, rev 1.10/2.08, addr 10> on usbus0
Sep 13 06:19:00 momh167-gjp4-8570p kernel: ugen0.6: <SteelSeries
SteelSeries Siberia 350> at usbus0 (disconnected)
Sep 13 06:19:12 momh167-gjp4-8570p kernel: ugen0.7: <SteelSeries
SteelSeries Siberia 350> at usbus0
Sep 13 06:19:12 momh167-gjp4-8570p kernel: uaudio1: <SteelSeries
SteelSeries Siberia 350, class 0/0, rev 1.10/2.08, addr 13> on usbus0
Sep 13 09:13:08 momh167-gjp4-8570p kernel: ugen0.4: <SteelSeries
SteelSeries Siberia 350> at usbus0
Sep 13 09:13:08 momh167-gjp4-8570p kernel: uaudio0: <SteelSeries
SteelSeries Siberia 350, class 0/0, rev 1.10/2.08, addr 3> on usbus0
root@momh167-gjp4-8570p:~ # tail /var/log/messages
Sep 13 10:11:39 momh167-gjp4-8570p kernel: pcm4: unregister: mixer busy
Sep 13 10:11:39 momh167-gjp4-8570p kernel: pcm4: Waiting for sound
application to exit!
Sep 13 10:11:39 momh167-gjp4-8570p kernel: pcm4: unregister: mixer busy
Sep 13 10:11:39 momh167-gjp4-8570p kernel: pcm4: Waiting for sound
application to exit!
Sep 13 10:11:39 momh167-gjp4-8570p kernel: pcm4: unregister: mixer busy
Sep 13 10:11:39 momh167-gjp4-8570p kernel: pcm4: Waiting for sound
application to exit!
Sep 13 10:11:39 momh167-gjp4-8570p kernel: pcm4: unregister: mixer busy
Sep 13 10:11:39 momh167-gjp4-8570p kernel: pcm4: Waiting for sound
application to exit!
Sep 13 10:11:39 momh167-gjp4-8570p kernel: pcm4: unregister: mixer busy
Sep 13 10:11:39 momh167-gjp4-8570p kernel: pcm4: Waiting for sound
application to exit!
root@momh167-gjp4-8570p:~ #

----

Clearly I'm doing something wrong.

If on-the-fly use of USB audio devices is not possible, then must I keep
the devices connected whilst I'm signed in to the desktop environment?
_______________________________________________
[hidden email] mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to "[hidden email]"
Reply | Threaded
Open this post in threaded view
|

Re: USB sound devices with FreeBSD-CURRENT

Hans Petter Selasky-6
On 2020-09-13 11:21, Graham Perrin wrote:

>
> 1. Chromium simply does not play AV content e.g.
> <https://www.ted.com/talks/james_geary_metaphorically_speaking> – after
> a click to play, there's a moment of visual motion but no playback
>
> 2. if Firefox media.cubeb.backend set to oss then behaviour is the same
> as Chromium
>
> 3. if Firefox media.cubeb.backend is not set (audio backend defaults to
> pulse-rust) then playback occurs through IDT 92HD81B1X (Analog) – not USB.

Try to configure a smaller audio buffer size in virtual_oss . Sometimes
devices request a very small audio buffer .

--HPS
_______________________________________________
[hidden email] mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to "[hidden email]"
Reply | Threaded
Open this post in threaded view
|

Re: USB sound devices with FreeBSD-CURRENT

Tomasz CEDRO
In reply to this post by grahamperrin
I am using EMU10K1 attached to the sound system over USB on my laptop
and the device needs to be connected on boot - unplug will crash the
system.

If device is plugged in on boot and I add `hw.snd.default_unit=3` to
`/etc/sysctl.conf`, that is before I start X, then I have audio
playback "by default".

In order to have dynamic audio configuration I have found PulseAudio
helpful a lot as it allows you to select which application uses which
input/otput audio device. Note that PulseAudio can lock your audio
hardware and block clean module removal.

I am not sure about current default sound system in FreeBSD if its
still OSS or ALSA, but if you do not want to use PulseAudio, you may
want to try ALSA configuration at `/usr/local/etc/asound.conf` it
allows some more detailed remap.

Good luck :-)
Tomek

--
CeDeROM, SQ7MHZ, http://www.tomek.cedro.info
_______________________________________________
[hidden email] mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to "[hidden email]"
Reply | Threaded
Open this post in threaded view
|

Re: USB sound devices with FreeBSD-CURRENT

Samy Mahmoudi
Hi,

If reducing the audio buffer size in virtual_oss does not solve the issue
and you temporarily resort to use PulseAudio to achieve switching devices
on-the-fly (which does work very well with PulseAudio), you could indeed
'keep the devices connected' and use a variant of the following script:

#!/usr/local/bin/zsh
SINK_INDEX1=1
SINK_INDEX2=4
ACTIVE_SINK=$(pacmd list-sinks | grep '* index:' | /usr/local/bin/grep -o
'[0-9]*')
if [ "$ACTIVE_SINK" = $SINK_INDEX1 ] ; then
    pacmd set-default-sink $SINK_INDEX2
    pacmd list-sink-inputs | awk '/index:/{print $2}' | xargs -r -I{} pacmd
move-sink-input {} $SINK_INDEX2
else
    pacmd set-default-sink $SINK_INDEX1
    pacmd list-sink-inputs | awk '/index:/{print $2}' | xargs -r -I{} pacmd
move-sink-input {} $SINK_INDEX1
fi

In its current form, it allowed me to switch devices on-the-fly with a
keyboard shortcut.

The problem is I had to use a poudriere to build relevant ports with option
PULSEAUDIO (chromium, firefox, mpv, audacious, virtualbox, etc.) and there
may have been (I can not remember precisely) another problem if the USB
headset was either hot-plugged or hot-unplugged. Please let us know if you
manage to sort this out with virtual_oss.
_______________________________________________
[hidden email] mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to "[hidden email]"
Reply | Threaded
Open this post in threaded view
|

Re: USB sound devices with FreeBSD-CURRENT

grahamperrin
In reply to this post by Hans Petter Selasky-6
Now with

On 13/09/2020 10:24, Hans Petter Selasky wrote:

> On 2020-09-13 11:21, Graham Perrin wrote:
>>
>> 1. Chromium simply does not play AV content e.g.
>> <https://www.ted.com/talks/james_geary_metaphorically_speaking> –
>> after a click to play, there's a moment of visual motion but no playback
>>
>> 2. if Firefox media.cubeb.backend set to oss then behaviour is the
>> same as Chromium
>>
>> 3. if Firefox media.cubeb.backend is not set (audio backend defaults
>> to pulse-rust) then playback occurs through IDT 92HD81B1X (Analog) –
>> not USB.
>
> Try to configure a smaller audio buffer size in virtual_oss .
> Sometimes devices request a very small audio buffer .
>
> --HPS

Now with virtual_oss and sndiod disabled (starting them when required
with onestart), with the buffer size reduced from 1024 to 256,

----

root@momh167-gjp4-8570p:~ # head -n 55 /usr/local/etc/rc.d/virtual_oss |
grep -v \#


. /etc/rc.subr

name=virtual_oss
desc="Virtual OSS device manager"
rcvar=${name}_enable
start_precmd="${name}_precmd"
start_cmd="${name}_start"
stop_cmd="${name}_stop"
virtual_oss_default_args="\
   -T /dev/sndstat \
   -S \
   -i 8 \
   -C 2 -c 2 \
   -r 48000 \
   -b 24 \
   -s 256 \
   -f /dev/dsp0 \
   -c 2 \
   -d dsp \
   -t dsp.ctl"
configs=

load_rc_config $name

root@momh167-gjp4-8570p:~ # service virtual_oss onestart ; service
sndiod onestart ; service virtual_oss onestatus ; service sndiod
onestatus ; cat /dev/sndstat
Starting Virtual OSS config dsp ... done
Starting sndiod.
virtual_oss is running as pid 5990.
sndiod is running as pid 6006.
Installed devices:
pcm0: <ATI R6xx (HDMI)> (play) default
pcm1: <IDT 92HD81B1X (Analog 2.0+HP/2.0)> (play/rec)
pcm2: <IDT 92HD81B1X (Analog)> (play/rec)
pcm3: <USB audio> (rec)
pcm4: <USB audio> (play/rec)
No devices installed from userspace.
root@momh167-gjp4-8570p:~ #

----

I get visual playback but nothing audible at the USB headset or analogue
loudspeakers.

I see device buffer sizes below but I don't know how to use those to
determine a usable setting for -s in /usr/local/etc/rc.d/virtual_oss

 From dmesg :

----

ugen0.5: <Alctron USB700 Alctron USB700> at usbus0
uhid1 on uhub2
uhid1: <Alctron USB700 Alctron USB700, class 0/0, rev 1.10/1.00, addr 4>
on usbus0
uaudio0 on uhub2
uaudio0: <Alctron USB700 Alctron USB700, class 0/0, rev 1.10/1.00, addr
4> on usbus0
uaudio0: No playback.
uaudio0: Record[0]: 48000 Hz, 1 ch, 16-bit S-LE PCM format, 2x8ms buffer.
uaudio0: Record[0]: 44100 Hz, 1 ch, 16-bit S-LE PCM format, 2x8ms buffer.
uaudio0: Record[0]: 32000 Hz, 1 ch, 16-bit S-LE PCM format, 2x8ms buffer.
uaudio0: Record[0]: 22050 Hz, 1 ch, 16-bit S-LE PCM format, 2x8ms buffer.
uaudio0: Record[0]: 16000 Hz, 1 ch, 16-bit S-LE PCM format, 2x8ms buffer.
uaudio0: Record[0]: 11025 Hz, 1 ch, 16-bit S-LE PCM format, 2x8ms buffer.
uaudio0: Record[0]: 8000 Hz, 1 ch, 16-bit S-LE PCM format, 2x8ms buffer.
uaudio0: No MIDI sequencer.
pcm3: <USB audio> on uaudio0
uaudio0: No HID volume keys found.
ugen0.6: <vendor 0x0424 product 0x2514> at usbus0
uhub8 on uhub2
uhub8: <vendor 0x0424 product 0x2514, class 9/0, rev 2.00/b.b3, addr 5>
on usbus0
uhub8: MTT enabled
uhub8: 4 ports with 4 removable, self powered
ugen0.7: <SteelSeries SteelSeries Siberia 350> at usbus0
uaudio1 on uhub8
uaudio1: <SteelSeries SteelSeries Siberia 350, class 0/0, rev 1.10/2.08,
addr 6> on usbus0
uaudio1: Play[0]: 48000 Hz, 2 ch, 16-bit S-LE PCM format, 2x8ms buffer.
uaudio1: Play[0]: 44100 Hz, 2 ch, 16-bit S-LE PCM format, 2x8ms buffer.
uaudio1: Play[0]: 22050 Hz, 2 ch, 16-bit S-LE PCM format, 2x8ms buffer.
uaudio1: Play[0]: 16000 Hz, 2 ch, 16-bit S-LE PCM format, 2x8ms buffer.
uaudio1: Play[0]: 11025 Hz, 2 ch, 16-bit S-LE PCM format, 2x8ms buffer.
uaudio1: Play[0]: 8000 Hz, 2 ch, 16-bit S-LE PCM format, 2x8ms buffer.
uaudio1: Record[0]: 48000 Hz, 2 ch, 16-bit S-LE PCM format, 2x8ms buffer.
uaudio1: Record[0]: 44100 Hz, 2 ch, 16-bit S-LE PCM format, 2x8ms buffer.
uaudio1: Record[0]: 22050 Hz, 2 ch, 16-bit S-LE PCM format, 2x8ms buffer.
uaudio1: Record[0]: 16000 Hz, 2 ch, 16-bit S-LE PCM format, 2x8ms buffer.
uaudio1: Record[0]: 11025 Hz, 2 ch, 16-bit S-LE PCM format, 2x8ms buffer.
uaudio1: Record[0]: 8000 Hz, 2 ch, 16-bit S-LE PCM format, 2x8ms buffer.
uaudio1: No MIDI sequencer.
pcm4: <USB audio> on uaudio1
uaudio1: HID volume keys found.

_______________________________________________
[hidden email] mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to "[hidden email]"
Reply | Threaded
Open this post in threaded view
|

Re: USB sound devices with FreeBSD-CURRENT

Hans Petter Selasky-6
On 2020-09-13 16:13, Graham Perrin wrote:
>    -f /dev/dsp0 \

Try:

-f /dev/dsp3

--HPS
_______________________________________________
[hidden email] mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to "[hidden email]"
Reply | Threaded
Open this post in threaded view
|

Re: USB sound devices with FreeBSD-CURRENT

Hans Petter Selasky-6
In reply to this post by grahamperrin
On 2020-09-13 16:13, Graham Perrin wrote:
> pcm3: <USB audio> (rec)
> pcm4: <USB audio> (play/rec)

Or:

-R /dev/dsp4 -P /dev/dsp4

-f /dev/dsp4

You can also add these parameters run-time via the GUI for virtual_oss.

--HPS
_______________________________________________
[hidden email] mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to "[hidden email]"
Reply | Threaded
Open this post in threaded view
|

Re: USB sound devices with FreeBSD-CURRENT

Hans Petter Selasky-6
On 2020-09-13 16:30, Hans Petter Selasky wrote:

> On 2020-09-13 16:13, Graham Perrin wrote:
>> pcm3: <USB audio> (rec)
>> pcm4: <USB audio> (play/rec)
>
> Or:
>
> -R /dev/dsp4 -P /dev/dsp4
>
> -f /dev/dsp4
>
> You can also add these parameters run-time via the GUI for virtual_oss.
>

As a follow up to this discussion I've lowered the default buffer
latency to 8ms, which is the default for all USB devices.

https://svnweb.freebsd.org/changeset/ports/548703

--HPS
_______________________________________________
[hidden email] mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to "[hidden email]"