mikebrady / shairport-sync

AirPlay and AirPlay 2 audio player
Other
7.21k stars 572 forks source link

Audio corruption (sound card related) #119

Closed moodeaudio closed 5 years ago

moodeaudio commented 9 years ago

Hi Mike,

User reports a lot of audio distortion when Airplay + DAC with XMOS based USB(UAC2) receiver. User description of issue is below and suggests XMOS part is "forcing 32bit" so I'm wondering whether this might be causing issue with shairport-sync.

Regards, Tim Curtis

USER REPORT "The DAC that fails is a special version of the CY-5100dsd with a XMOS USB part. The XMOS is forcing 32bit audio transfer and that might be part of the problem with Airplay, although it works fine with local file playback. When I use a CM6632A based USB (shipping version of the CY-5100dsd MK-II, 24bit max), then Airplay works fine."

mikebrady commented 9 years ago

Hi Tim. Is it possible to find out what XMOS part is being used? Shairport Sync sets the rate to be 44.1/16 stereo. If it can't do that, it will simply die. It's hard to understand how it could be working at all if it was somehow moving to something actually incompatible. So, I'm inclined to think there might be some other explanation, like a bad alsa driver for UAC2, but that's really a shot in the dark. There is one parameter worth adjusting – the desired DAC buffer length, audio_backend_buffer_desired_length. It's in the alsa section of the /etc/shairport-sync.conf file and is set to 6615 frames by default. It would be worth uncommenting it and setting it to, say, 22050 (0.5 seconds) to see if it makes any difference.

I wonder if there are any "accessible" (i.e. cheap) XMOS-based devices around that one could try things out on...

moodeaudio commented 9 years ago

Hi Mike,

My thought was same that its the buggy USB driver in 3.18 series kernels thats not handling UAC2 correctly causing audio distortion. There is a workaround for this: Add "dwc_otg.fiq_fsm_mask=0x3" to the beginning of line in /boot/cmdline.txt.

The user has the workaround configured and it fixed the distortion issue for local playback. Maybe the workaround is what is causing issues for Airplay and we have a catch-22 scenario. I'll ask him to test this out.

Regards, Tim

mikebrady commented 8 years ago

Hi Tim. I was wondering if there's been any developments at your user's end on this issue? Regards, Mike

moodeaudio commented 8 years ago

Hi Mike,

Still an issue. I'm running 4.1.10+ kernel with Moode 2.4 and USB(UAC2) still seems to be broken for XMOS and CMEDIA chipsets with output from Airplay. Local output still requires dwc_otg.fiq_fsm_mask=0x3 workaround.

Here is the thread that references the issue in the USB driver in 3.18 kernels. https://github.com/raspberrypi/linux/issues/888 Search for "Yep, it's broken" to get to the relevant posts.

I was hoping the USB fixes would be in 4.1.10 but it does not appear to be so.

Regards, Tim

mikebrady commented 5 years ago

Closing this due to inactivity. Feel free to open a new issue.