-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
USB Audio setting sample rate broken #197
Comments
It's hard to imagine this being caused by anything in firmware or kernel. P33M, could this be a usb issue? |
I also find it hard to imagine... but it's totally reproducible and as far as I can tell the only change is the firmware (or, at least, something updated by rpi-update). Config: Verify Works: Break: |
If you look here: you should see all the firmware updates. You shoud be able to run: where hash is to get back to an older firmware. If you can track down the commit that broke sampling rate, then we'd have a better idea of the cause. |
Ok, I'll start at that commit and work forwards/backwards until it breaks. There's quite a few commits between now and 25th May, I really hope I don't have to go in that direction! |
Chris, you want to perform a rough binary search: |
I thought a bogo-search might have been better ;) I don't have anything to feed the inputs just now (trains are not known for their availability of line level sources and RCA cables, not even the high speed ones) - so will have to continue the quest to find the commit later. However I have noticed that going back to fcc46f1c9aad95e28fd254f5153764fb47d68cf7 did cause my USB device to emit lots of stuff to dmesg on capture
|
I think I've tracked it down. The first revision to cause issues is 44dc4f093c9ec075e6704965665311a94f6371aa . All the ones before this have the clicking, but at least the sample rate is right. |
To be clear, is the only time you are seeing the distorted sample rate when you are recording audio? |
That is correct - it's just capture that has this issue. If you're playing back and capturing at the same time, it gets considerably weirder sounding. For example:
Playback works fine, regardless of the samplerate of the source file - no clicks or pops either. |
I've reproduced this issue with playback at least, not tested record yet.. It's with the way fiq_split now uses exclusive access to each TT. Before fiq_split, the driver used to do both start and completes of split transactions out of order, especially in the case of a missed complete, which caused problems with repeated keypresses etc. Fiq_split now enforces that these are done one at a time to prevent packet loss, which is critical for keyboard interaction. If you are sourcing audio from the device then a split-isoc IN can take up to 5 microframes to complete. If we did a 3-microframe interrupt IN transfer in the same frame (due to the HID endpoint) then we will run out of time to complete the transaction which means we never ask for data from the audio device. What this and other usb audio devices tend to do here is one of two things
The reason the audio then works fine at 32kHz is because you drop down to a single split-complete of <188 bytes which then takes just 3 microframes. This and the occasional HID endpoint will fit with the current allocation requirement. A workaround could be to clobber the HID endpoint or blacklist the device ID so that usbhid doesn't pick it up. It is still possible to get glitches in playback if you have high interrupt loading from elsewhere (ethernet or mass storage) - we miss scheduling isoc OUTs in a timely fashion which causes hubs to drop packets. Duplex audio is probably never going to work - unless you use sample rates <32kHz for both in and out. |
Okay - that makes sense. It also explains why the pitch in the sound Can I blacklist the device myself, and if so, what method would be Also, given for my current project I have no keyboards attached, can I
|
I've just put the analyzer on the very same device and there is a bug with the fiq_split for multi-complete INs. We currently can only do a single-packet isoc IN transaction which in theory would limit us to 44.1k 16-bit but in practice the hub will only return 172 of the the 176 bytes (because we are so close to the actual end of the data, the hub will keep some bytes behind to ensure it doesn't accidentally munge the full-speed CRC at the end of the packet into the high-speed data). 32k 16bit record is all we can manage for now. To test with disabling the HID endpoint, which may help with crackling playback, you can do
This is a one-time-only unbind - reboot or replug will cause USBhid to rebind to it. I tried with remove_id which should dynamically remove the audio device's id from the support table, but I think usbhid is just the default for any HID device and thus doesn't have the ID. The kernel from rpi-update is built with usbhid integrated so you can't disable it via /etc/modprobe.d/*. You could rebuild it yourself from source with hid as a module. |
Can you test with |
I think I am having the same problem described in this thread. I recently installed a usb sound card with C-Media chipset (Audio-Technica ATR2USB). Playback is fine, but recording seems to record at a lower sampling rate than the specified 48K or 44.1K or whatever I specify. Play back is higher freq and distorted. Is there a fix for this? |
This issue is no longer present in the fiq_fsm rewrite. Stereo capture at up to 48kHz should work fine, even in duplex with playback to the same device. |
At some point between the firmware shipped with 2013-05-25-wheezy-raspbian and the current head (i.e. after running rpi-update), something is preventing the successful setting of the sample-rate of my PCM2902 based USB audio device.
lsusb snippet
lsusb -v https://gist.github.com/naxxfish/6062180
Using gstreamer as a client, running this:
Results in:
However, the audio is actually only being sampled at 32kHz (verified by looking at a recorded wav file created using filesink) - therefore further processing of the audio is causing it to be pitched up and distorted with frequent gapping, due to the misrepresentation of the sample rate.
Running
Produces correct audio.
The older firmware version as in the stock wheezy image does not exhibit this issue.
Forum topic:
http://www.raspberrypi.org/phpBB3/viewtopic.php?f=28&t=50589&sid=c528ca3d4420e5fca78143f94c06113a
The text was updated successfully, but these errors were encountered: