-
-
Notifications
You must be signed in to change notification settings - Fork 582
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
Stuttering audio using USB Creative SoundBlaster MP3+ #167
Comments
Thanks for this interesting post. I'm not an expert on this stuff at all, but it looks to me that your |
Ah yes, sorry I missed that bit of info. The card has an analogue and digital mode and both input and output. I believe from some reading online and interrogation of the card that it's capable of 48khz playback in analog mode and 44.1khz or 48khz in digital and for capture. Looking at the output of
If I use the default asound.conf above with no resampling I get the following shairport message but it seems to continue (albeit with no audio)
So I first tried with and without resampling to 44100 in ALSA by setting the plug rate to 44100 or 48000 and it didn't seem to make a difference to the stuttering. So decided to stick with 48000 and adjust for frames of that size, which then got things working smoothly. Interestingly audio being played directly through mopidy from local files or streamed radio 'just worked' no matter if I resampled or not. |
Thanks for the interesting update. I guess that the difference between Shairport Sync and Mopidy is related to the fact that, to maintain synchronisation, Shairport Sync is continually checking the latency of the output device whereas Mopidy isn't. It might be worth looking to see if the checking could be done less frequently, or something, but that's a long way off just yet. Many thanks. |
Sounds like I've not missed anything obvious then. I think as a next step I'll speak to the Pi MusicBox guys and look at adding a latency option to the configuration. Shouldn't be too difficult from what I've seen of the setup so far and will hopefully help others. Thanks for the responses and the very cool software :) I'll mark this issue as closed. |
Thanks |
Hello again Mike, I may try and morph this into a feature request... :) So right now I've got the above magic fudge in /etc/asound.conf but this is explicitly to get shairport-sync to work, other players (like mpd, mopidy, etc) don't need it and it seems like a not ideal overhead to have all the time. Would you be open to exposing additional alsa configurations in /etc/shairport-sync.conf for things like period_size and buffer_size which would allow a configuration like this:
If this is of no use to anyone but me and my awkward old USB DAC then no worries, but I thought it's worth discussing. |
Thanks for the message. What I think you've done at #167 (comment) above is create a virtual I would be reluctant to involve Shairport Sync in creating a virtual Many a better approach would be to write up a quick note about the technique and put it into the new Troubleshooting page. What to you think? |
Setting period and buffer size requires an alsa dmix plugin as you did in your asound.conf. This might not be configured for all users. Also, it is very common to adjust these values in asound.conf, so I agree with Mike here. |
Thanks for the replies. Apologies if I wasn't clear, I have indeed needed to create a virtual alsa device/dmix plugin to get Shairport Sync to work on my Raspberry Pi with various distributions (PiMusicBox/Volumio/etc). My concern is that this is a special case required only for Shairport Sync to work, hence why I suggested a method for it to be handled within Shairport Sync. This would keep things isolated and clean in terms of (external) implementation and I think make handling of this special case far easier in terms of changes to things like Volumio/PiMusicBox. Other sources/players such as mpd/mopidy/aplay work without the adjustment of period and buffer so having the fudge in places globally also just seems like overkill. The conversion of 44.1k to 48k is a bit of a red herring, this is not absolutely necessary in my testing of the hardware I'm using, but it seemed to be the right thing to do from the capabilities it reported, so I included it for completeness. I guess I could create a virtual alsa device specifically for use by shairport (i.e. not set it as default), but I'm less certain support for this would be easily patchable into something like Volumio. For me this problem is easy to solve on my setup my changing files manually and will be going away soon as I'm moving to using an iQAudio DAC now but it would be nice to tie up the loose ends especially for others. I completely understand not wanting to complicate Shairport Sync though Mike. I'll definitely write something more concise and clear for the Troubleshooting page :) |
Thanks for this contribution. Please open a new issue if necessary. |
Hi Mike,
So.. first up I've 'solved' the issue which is stuttering audio with shairport-sync using a USB Creative SoundBlaster MP3+ with Pi MusicBox which didn't work out of the box as it were. I'm hoping that with your expertise we can see whether this is a bug in shairport-sync or elsewhere before I suggest a change to Pi MusicBox. Or if this is a wonderful quirk of dodgy old hardware :)
I'm running MusicBox 0.6 (http://www.pimusicbox.com) which includes
This is running on a rev 1 Raspberry Pi Model B
By default /etc/asound.conf is
My USB sound card (an old Creative Soudblaster MP3+ running via an external powered hub due to it's 500mA power requirement) works fine for playing audio through mopidy with this default, but stutters terribly and sometimes doesn't even play at all with shairport-sync.
Looking at the default settings used I can see this
This would (if my new found understanding of ALSA is correct) give us an interrupt every 6000_4 = 24000 bytes or (24000/192000 = 0.125) every 125ms and a buffer of 18000_4 = 72000 Bytes or 72kB.
There are no errors from in shairport itself (from running with -vvv --statistics) so I assumed something in ALSA land, perhaps related to funkiness of timing, latency and the USB on the Pi or with DMA and USB Audio devices, so set about tweaking period_sizes and buffer_sizes.
There were sync errors reported for most of the settings but rarely or no missing or late packets and no audible hiccups so I've not included these.
It looks as if having too large a buffer causes out of sequence problems and too large a latency causes stuttering. Which I guess makes sense! I settled on this setup which seems to work fine
Any thoughts on why this stuttering only occurs when using shairport-sync and not mopidy/aplay with the default settings? Have I missed anything here?
Thanks.
The text was updated successfully, but these errors were encountered: