How I got Spotify to stream without stuttering on my Rpi2

Raspberry Pi related support

How I got Spotify to stream without stuttering on my Rpi2

Postby christo4 » 22 Apr 2015, 17:25

This post is for anyone who is frustrated like I was because Spotify stutters, skips, or hiccups.
First a little background: I have a Raspberry Pi 2 Model B with an IQaudIO Pi-Dac+. I am running Rune Audio 0.3 beta (the March 4 image). I have the RCA jacks on my Pi-Dac+ hooked up to a stereo receiver. I have a USB WiFi dongle, which connects wirelessly (n) to my Actiontec C1000A DSL modem. My internet is supplied by CenturyLink at 7 Mbps.

When I first installed Runeaudio, it played MP3s from a USB drive just fine. However, when I connected to Spotify, I had disappointing results. It would play for a second, then stutter, play for a while, then cut out altogether. Sometimes the UI would become completely unresponsive and I would have to reboot it. Below is a list of changes I made in the order that I made them to fix these problems. Each change made a noticeable difference, but I do not know which ones were truly decisive. Now that the system works, I have not gone back to test all the possible combinations. My hypothesis is that I had a combination of issues related to power management and network congestion. Anyway, here is what I did (YMMV):

    1. Moved the USB thumb drive to a powered USB hub like this one.
    3. Replaced the power supply. I have read that Raspberry Pi's are notoriously finicky about power. I had originally used this one. When I switched to this one from Monoprice, I got much better results. The short stuttering was virtually eliminated. However, it would still pause for 20 seconds or more on about every other song.
    4. Set the Playback Boost in alsamixer to 0 dB. I have played with the alsamixer settings endlessly to try to solve this issue. The setup that seems to work for me is as follows: PCM=85, Playback=100 (0 dB), Playback Boost=0 (0 dB).
    5. Configured my wifi router to prioritize bandwidth. The final step in my journey was to adjust the Quality of Service (QoS) settings for my modem/wifi router to give high priority to downstream traffic to my Rpi's ip address.
christo4
 
Posts: 5
Joined: 13 Mar 2015, 19:51

Re: How I got Spotify to stream without stuttering on my Rpi

Postby bevlar » 23 Apr 2015, 00:33

Hi Christo. I'm 99% sure that it was the powered hub that solved your issue.

Here's my reasoning:

1. You had no issues playing local files. This proves that your DAC hat and rune installation are both fine.

2. The DAC draws power from your pi not an external power supply. This meant that you had a WiFi adapter, DAC and thumb stick all powered from the pi. Combined they require more current than the pi can provide. This also explains why lowing the volume in alsamixer improved the problem, lower volumes require less current. The same applies for the original WiFi adapter, it probably requires less current to operate.

3. Experience, I have a creative sound blaster x-fi USB DAC that I cannot use with my WiFi adapter without a hub. If I try to play music from Spotify or a network share I experienced similar problems as you, possibly worse as my runeui session would disconnect and it was hit or miss whether it would reconnect when I refreshed.

If you have a spare SD card, flash runeaudio and try streaming Spotify with the original components connected via the hub and no other changes.

Edit: corrected a few words.
bevlar
 
Posts: 26
Joined: 16 Mar 2015, 10:52

Re: How I got Spotify to stream without stuttering on my Rpi

Postby christo4 » 23 Apr 2015, 01:56

Bevlar, that makes sense, and I do think the USB hub is important. However, the hub alone did not completely solve the problem for me. I forgot to mention that I also experimented with using the WiFi dongle on the powered USB hub, but that did not make as much of a difference. I also forgot to add in my post that at some point I switched from a Sandisk class 4, 16 GB micro SD card to a Samsung class 6, 8 GB card. That seemed to help too. Anyway, the issue was not completely solved for me until I adjusted the ALSA settings and the WiFi priority.
christo4
 
Posts: 5
Joined: 13 Mar 2015, 19:51

Re: How I got Spotify to stream without stuttering on my Rpi

Postby tmilovan » 27 Mar 2016, 17:18

The solution for this kind of problems is usually just to turn the caching on and write it to ram disk like it is stated here: https://github.com/Schnouki/spop/issues/40

If this is for some reason not feasible try to set the cache_path to point to some fast mount on your system.

Hope this helps someone :)
tmilovan
 
Posts: 11
Joined: 27 Mar 2016, 17:11

Re: How I got Spotify to stream without stuttering on my Rpi

Postby hondagx35 » 27 Mar 2016, 21:20

Hi y tmilovan,

thank you for the hint.

On all newer images caching is on and pointing to the ram disk.
Code: Select all
### Cache settings ###
#cache_size = 0
cache_path = /tmp/spop

cache_size = 0 is the default setting and will use 10% of free disk space.

Frank
User avatar
hondagx35
 
Posts: 3042
Joined: 11 Sep 2014, 22:06
Location: Germany

Re: How I got Spotify to stream without stuttering on my Rpi

Postby tmilovan » 23 Apr 2016, 11:03

Aw nice :). Glad it helped :).
tmilovan
 
Posts: 11
Joined: 27 Mar 2016, 17:11

Re: How I got Spotify to stream without stuttering on my Rpi

Postby rastus » 25 Apr 2016, 04:41

Need to check the USB hub's power supply, 5V 2A+... I went for 5V 4A after trying a few of lower Amps. Made a difference when using a wifi dongle, USB HDD and USB flash drive at the same time.... it even powers the Pi at the same time as those three items.
User avatar
rastus
 
Posts: 353
Joined: 21 Aug 2015, 10:29

Re: How I got Spotify to stream without stuttering on my Rpi

Postby dernew » 21 Dec 2016, 19:44

I get exactly the same issue as described at the top of this thread. Spotify stutters at random with breaks from a few seconds to several minutes. Web radio on MPD is generally fine and in use for most of the day. I have a simple set-up, just a Pi and some active Speakers , no DAC yet until this issue is solved. I've tried everything in this thread and others. i.e. power supply check, network check, switching-off logging in spotify, checking the cache etc. I had a ssh connection running with 'top' to monitor the pi and the processors and memory are all at a low use level and during a pause there is no significant change . I eliminated wifi and connected directly to my router via ethernet, same issue. I have switched from a Pi2 where the problem was first encountered and done a fresh build with a Pi3 [albeit with the same version of Runeaudio
RuneAudio_rpi2_rp3_0.4-beta_20160321] with a different power supply and different connection point. Same issue. Both Pi's used [different] class 10 sd cards which I checked for i/o errors before flashing. I've had issues with corrupt sd cards in the past with other Pi applications.
So I'm guessing the issue is to do with cache or I/O but it is beyond my skills and have spent many hours puzzling over it.
Spotify itself runs fine when I run the native application from a PC.

Runeaudio is such a good platform, it has transformed my listening and that's why I added a spotify subscription ! :D

Anyway any advice or insight greatly appreciated.

Thanks
dernew
 
Posts: 2
Joined: 21 Dec 2016, 16:41

Re: How I got Spotify to stream without stuttering on my Rpi

Postby christo4 » 23 Dec 2016, 23:11

I recently upgraded my Internet bandwidth from 1.5MB to 7MB over DSL, and no longer experience any issues. I now think that the stuttering had something to do with my Internet seed, even though Spotify would play just fine through PC or on my phone (wifi) with the lower bandwidth. I think for some reason the Pi needed a more constant stream of higher bandwidth internet. What's your connection seed?
christo4
 
Posts: 5
Joined: 13 Mar 2015, 19:51

Re: How I got Spotify to stream without stuttering on my Rpi

Postby dernew » 17 Jan 2017, 14:32

Thanks
Agree that the Pi seems to need a good and consistent connection speed.
I am lucky to have a hi speed broadband connection, it typically gives 50Mb/s download speed. So I m doubtful that is to blame, although more people using video download causes the class of service on these links to get time sliced I believe. So not impossible.
Spotify is still causing issues and is not really usable on any either a Pi 2 or a Pi 3, Due to the long pauses in playback :? . Just trying it again as I type on a Pi3 and it has played 3 tracks without a gap and then a gap of 3 minutes before it plays again. Played for 4 minutes then another long pause of about a minute.
I've also gone away leaving it playing for several hours and have had to restart the Pi since it becomes unresponsive. Real shame.
System in use most of the day for web radio.

I'm surprised if I am the only one having this issue?
dernew
 
Posts: 2
Joined: 21 Dec 2016, 16:41

support RuneAudio Donate with PayPal


Return to Raspberry Pi

Who is online

Users browsing this forum: No registered users and 13 guests
cron