Bug 208791 - USB audio playback issue
Summary: USB audio playback issue
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: usb (show other bugs)
Version: 10.3-RELEASE
Hardware: amd64 Any
: --- Affects Only Me
Assignee: Hans Petter Selasky
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-04-14 03:30 UTC by alex
Modified: 2016-11-18 07:14 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description alex 2016-04-14 03:30:03 UTC
Using a USB DAC (AudioQuest DragonFly) I get clicking and popping (vinyl-like).  With FreeBSD 9.3 I was able to get clean output by setting the default sample rate to 44100.  With 10.3 that is not the case.

This is the device:

uaudio0: <AudioQuest inc. AudioQuest DragonFly, class 0/0, rev 1.00/1.0c, addr 10> on usbus1
uaudio0: Play: 44100 Hz, 2 ch, 24-bit S-LE PCM format, 2x8ms buffer.
uaudio0: Play: 96000 Hz, 2 ch, 24-bit S-LE PCM format, 2x8ms buffer.
uaudio0: Play: 88200 Hz, 2 ch, 24-bit S-LE PCM format, 2x8ms buffer.
uaudio0: Play: 48000 Hz, 2 ch, 24-bit S-LE PCM format, 2x8ms buffer.
uaudio0: Play: 44100 Hz, 2 ch, 24-bit S-LE PCM format, 2x8ms buffer.
uaudio0: No recording.
uaudio0: No MIDI sequencer.
pcm3: <USB audio> on uaudio0
uaudio0: No HID volume keys found.

# sysctl dev.pcm.3
dev.pcm.3.feedback_rate: 44049
dev.pcm.3.mixer.mute_1.desc: AudioQuest DragonFly
dev.pcm.3.mixer.mute_1.max: 1
dev.pcm.3.mixer.mute_1.min: 0
dev.pcm.3.mixer.mute_1.val: 0
dev.pcm.3.mixer.vol_0_1.desc: AudioQuest DragonFly
dev.pcm.3.mixer.vol_0_1.max: 53
dev.pcm.3.mixer.vol_0_1.min: 0
dev.pcm.3.mixer.vol_0_1.val: 29
dev.pcm.3.mixer.vol_0_0.desc: AudioQuest DragonFly
dev.pcm.3.mixer.vol_0_0.max: 53
dev.pcm.3.mixer.vol_0_0.min: 0
dev.pcm.3.mixer.vol_0_0.val: 29
dev.pcm.3.bitperfect: 0
dev.pcm.3.buffersize: 0
dev.pcm.3.play.vchanformat: s16le:2.0
dev.pcm.3.play.vchanrate: 44100
dev.pcm.3.play.vchanmode: fixed
dev.pcm.3.play.vchans: 1
dev.pcm.3.hwvol_mixer: vol
dev.pcm.3.hwvol_step: 5
dev.pcm.3.%parent: uaudio0
dev.pcm.3.%pnpinfo: 
dev.pcm.3.%location: 
dev.pcm.3.%driver: pcm
dev.pcm.3.%desc: USB audio

I do seem to see these with debugging turned up:

uaudio_chan_play_sync_callback: Comparing 44149 Hz :: 44100 Hz
Comment 1 Hans Petter Selasky freebsd_committer freebsd_triage 2016-04-14 07:07:20 UTC
Can you collect a few of these and show how they change over time?
Comment 2 alex 2016-07-26 01:07:02 UTC
With this kernel:

FreeBSD bloaty 10.3-RELEASE-p4 FreeBSD 10.3-RELEASE-p4 #0: Sat May 28 12:23:44 UTC 2016     root@amd64-builder.daemonology.net:/usr/obj/usr/src/sys/GENERIC  amd64

And hw.snd.verbose=4

I see:

pcm3: WARNING: PCMDIR_PLAY DMA completion too fast/slow ! hwptr=0, old=0 delta=0 amt=0 ready=4236 free=0

With hw.usb.uaudio.debug=15

I see:

uaudio_chan_play_sync_callback: Comparing 44149 Hz :: 44100 Hz

This doesn't appear to vary, and has appeared consistent with the 10.3 kernels.  The same hardware worked without fault in 9.x.  Sorry for the delay, but this machine is unsuitable for audio playback currently so I've not tried in a while.
Comment 3 Hans Petter Selasky freebsd_committer freebsd_triage 2016-07-27 14:57:07 UTC
Hi,

Do you have a link where such a device can be bought? Used or new?

There has been updates in the USB audio driver which might have broken your device, but fixed others.

--HPS
Comment 4 alex 2016-08-21 04:56:50 UTC
I believe I purchased mine from Amazon, although the version I have (1.2, IIRC) has since been discontinued.
Comment 5 metsuke 2016-10-03 03:46:07 UTC
Perhaps this is the same issue that causes my Razer Megalodon (USB headset) to constantly crackle as well.  It was nearly fixed by hselasky's suggestion: 
-----
Edit:

sys/dev/usb/usb_freebsd.h

And change:

#define USB_FS_ISOC_UFRAME_MAX 4 /* exclusive unit */

Into:

#define USB_FS_ISOC_UFRAME_MAX 5 /* exclusive unit */

Then re-build the kernel.
-----

There is still a crackle for 2 seconds every time a new audio stream starts, but it goes away after that.  I thought the 11.0 upgrade would fix this, but I still need a custom kernel.  If this is not the same issue, I'll open a new one, thanks.
Comment 6 commit-hook freebsd_committer freebsd_triage 2016-11-08 08:10:40 UTC
A commit references this bug:

Author: hselasky
Date: Tue Nov  8 08:09:49 UTC 2016
New revision: 308437
URL: https://svnweb.freebsd.org/changeset/base/308437

Log:
  Range check the jitter values to avoid bogus sample rate adjustments.
  The expected deviation should not be more than 1Hz per second. The USB
  v2.0 specification also mandates this requirement. Refer to chapter
  5.12.4.2 about feedback.

  PR:		208791
  MFC after:	3 days

Changes:
  head/sys/dev/sound/usb/uaudio.c
Comment 7 Hans Petter Selasky freebsd_committer freebsd_triage 2016-11-08 08:11:14 UTC
I believe your issue is fixed after another FreeBSD user reported a similar issue with the same USB audio device. Please test the patch mentioned above in this PR.
Comment 8 commit-hook freebsd_committer freebsd_triage 2016-11-09 07:10:22 UTC
A commit references this bug:

Author: hselasky
Date: Wed Nov  9 07:09:27 UTC 2016
New revision: 308461
URL: https://svnweb.freebsd.org/changeset/base/308461

Log:
  Allow higher sample rates to have more jitter than lower ones.

  PR:		208791
  MFC after:	3 days

Changes:
  head/sys/dev/sound/usb/uaudio.c
Comment 9 commit-hook freebsd_committer freebsd_triage 2016-11-12 17:28:25 UTC
A commit references this bug:

Author: hselasky
Date: Sat Nov 12 17:27:28 UTC 2016
New revision: 308571
URL: https://svnweb.freebsd.org/changeset/base/308571

Log:
  MFC r308437 and r308461:
  Range check the jitter values to avoid bogus sample rate adjustments.
  The expected deviation should not be more than 1Hz per second. The USB
  v2.0 specification also mandates this requirement. Refer to chapter
  5.12.4.2 about feedback.

  Allow higher sample rates to have more jitter than lower ones.

  PR:		208791

Changes:
_U  stable/11/
  stable/11/sys/dev/sound/usb/uaudio.c
Comment 10 commit-hook freebsd_committer freebsd_triage 2016-11-12 17:31:27 UTC
A commit references this bug:

Author: hselasky
Date: Sat Nov 12 17:30:55 UTC 2016
New revision: 308572
URL: https://svnweb.freebsd.org/changeset/base/308572

Log:
  MFC r308437 and r308461:
  Range check the jitter values to avoid bogus sample rate adjustments.
  The expected deviation should not be more than 1Hz per second. The USB
  v2.0 specification also mandates this requirement. Refer to chapter
  5.12.4.2 about feedback.

  Allow higher sample rates to have more jitter than lower ones.

  PR:		208791

Changes:
_U  stable/10/
  stable/10/sys/dev/sound/usb/uaudio.c
Comment 11 commit-hook freebsd_committer freebsd_triage 2016-11-12 17:32:29 UTC
A commit references this bug:

Author: hselasky
Date: Sat Nov 12 17:32:23 UTC 2016
New revision: 308573
URL: https://svnweb.freebsd.org/changeset/base/308573

Log:
  MFC r308437 and r308461:
  Range check the jitter values to avoid bogus sample rate adjustments.
  The expected deviation should not be more than 1Hz per second. The USB
  v2.0 specification also mandates this requirement. Refer to chapter
  5.12.4.2 about feedback.

  Allow higher sample rates to have more jitter than lower ones.

  PR:		208791

Changes:
_U  stable/9/sys/
  stable/9/sys/dev/sound/usb/uaudio.c
Comment 12 commit-hook freebsd_committer freebsd_triage 2016-11-12 17:37:31 UTC
A commit references this bug:

Author: hselasky
Date: Sat Nov 12 17:36:28 UTC 2016
New revision: 308574
URL: https://svnweb.freebsd.org/changeset/base/308574

Log:
  MFC r308437 and r308461:
  Range check the jitter values to avoid bogus sample rate adjustments.
  The expected deviation should not be more than 1Hz per second. The USB
  v2.0 specification also mandates this requirement. Refer to chapter
  5.12.4.2 about feedback.

  Allow higher sample rates to have more jitter than lower ones.

  PR:		208791

Changes:
_U  stable/8/sys/
_U  stable/8/sys/dev/
_U  stable/8/sys/dev/sound/
_U  stable/8/sys/dev/sound/usb/
  stable/8/sys/dev/sound/usb/uaudio.c
Comment 13 alex 2016-11-17 22:25:27 UTC
Looks good.
Comment 14 Hans Petter Selasky freebsd_committer freebsd_triage 2016-11-18 07:14:40 UTC
You means sounds good ;-)

Thank you for testing!