ISO icon indicating copy to clipboard operation
ISO copied to clipboard

Stuttery sound with some (but not all) USB audio devices

Open probonopd opened this issue 2 years ago • 4 comments

Describe the bug

Sound playback is not interrupted (stutters) e.g., when doing heavy work or clicking on the sound icon in the menu when using this specific USB sound device: "Virtual 7.1Ch Sound" (ID 0d8c:000c C-Media Electronics, Inc. Audio Adapter).

image

However, when using another USB sound device (USB microphone that also does playback via the headphone jack, ID 17a0:0304 Samson Technologies Corp. Q2U handheld mic with XLR), this does not happen.

Expected behavior

Sound playback is not interrupted e.g., when doing heavy work or clicking on the sound icon in the menu with any USB sound device.

Version (please complete the following information):

helloSystem 0.7.0 (Build 0G48) FreeBSD kernel version: 13.0-RELEASE FreeBSD userland version: 13.0-RELEASE

probonopd avatar Nov 13 '21 22:11 probonopd

The device does not have this issue e.g., on Linux or the Mac.

Are not all USB audio devices using the same USB audio driver in FreeBSD and hence should behave identically?

How can this be debugged?

probonopd avatar Nov 13 '21 22:11 probonopd

Starting point for debugging: https://twitter.com/probonopd/status/1459659722085253122 and https://wiki-dev.freebsd.org/Sound#Troubleshooting

% sysctl hw.snd.verbose=2
# Where does all the verbosity go?

% man -k snd_uaudio 
snd_uaudio(4) - USB audio and MIDI device driver

# Also check
sysctl hw.snd 

probonopd avatar Nov 13 '21 23:11 probonopd

Great way to reproduce extreme stuttering: Open https://mmontag.github.io/dx7-synth-js/ in Falkon, select midi/cantaloup.mid from the bottom-right dropdown menu, click "Play", and listen to the C-Media stuttering like crazy.

TODO: Compare the same hardware and website performance on other operating systems.

probonopd avatar Jan 08 '22 23:01 probonopd

A Plantronics branded USB audio adapter ("USB Adapter-01" printed on the back label) that came with a headset also identifies itself as 0d8c:000c (same USB ID as the cheap stuttery one). This device does NOT suffer from the same issue. It works properly.

So this could mean:

  • This C-Media based device gets configured differently (e.g., other buffer sizes) than other C-Media based devices in FreeBSD (maybe based on some configuration stored in the USB descriptors?)
  • The ones that are not properly working are C-Media fakes and/or have hardware defects
  • Other possibilities?

Is there a way to see and compare all parameters for the two different 0d8c:000c based devices?

Bad one:

ugen5.2: <vendor 0x0d8c C-Media USB Headphone Set> at usbus5
uaudio0 on uhub3
uaudio0: <vendor 0x0d8c C-Media USB Headphone Set, class 0/0, rev 1.10/1.00, addr 2> on usbus5
uaudio0: Play[0]: 48000 Hz, 2 ch, 16-bit S-LE PCM format, 2x8ms buffer.
uaudio0: Play[0]: 44100 Hz, 2 ch, 16-bit S-LE PCM format, 2x8ms buffer.
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: No MIDI sequencer.
pcm3: <USB audio> on uaudio0
uaudio0: HID volume keys found.

Good one:

ugen5.2: <vendor 0x0d8c C-Media USB Headphone Set> at usbus5
uaudio0 on uhub3
uaudio0: <vendor 0x0d8c C-Media USB Headphone Set, class 0/0, rev 1.10/1.00, addr 2> on usbus5
uaudio0: Play[0]: 48000 Hz, 2 ch, 16-bit S-LE PCM format, 2x8ms buffer.
uaudio0: Play[0]: 44100 Hz, 2 ch, 16-bit S-LE PCM format, 2x8ms buffer.
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: No MIDI sequencer.
pcm3: <USB audio> on uaudio0
uaudio0: HID volume keys found.

So from dmesg they appear indistinguishable, but they behave very differently.

The bad ones have a epoxy blob instead of a chip housing.

probonopd avatar Feb 09 '22 20:02 probonopd