-
Notifications
You must be signed in to change notification settings - Fork 17
Laggy Audio Stream on RaspberryPi #28
Comments
Yes. The audio example is too low performance to work on raspberry pi, the processor is simply not fast enough. I have two experimental branches since checking this problem out a few weeks ago:
Using the gems from the two experimental versions above allowed me to play audio without lag on raspberry pi. You're welcome to try them. There have not been a release with these branches, because I'm thinking of possibly merging plaything and the spotify gem... maybe. How to handle audio playback in this library is a bit complex. I want to ship a nice default solution, but still allow people to make advanced custom drivers if they ever want to. |
sorry for double-Posting this issue. I saw that this topic was discussed in some old threads. I will try your branches. |
Don't worry. I like to keep this issue open. It reminds me that some change needs to be made for the spotify gem to work well on raspberry pi. |
Tried to use the raspberry-pi branch now without success. example-audio_delivery_speed.rb seems to work, but i can't hear any audio.
example-audio_stream.rb gives:
Any Idea what could be wrong? |
Could you give me some Information with wich OS/Config you tested these branches, so i could replicate this working system? |
Hm. I've seen segfaults on Raspberry PI earlier. Last time I had audio playback work, I was actually surprised that it did not segfault, as I recall an earlier attempt caused random segfaults at just about any time. I can't remember what setup I used earlier. I am fairly certain it was one of the mentioned OSes for the official downloads: http://www.raspberrypi.org/downloads/. Since the branch includes a special version of spotify to support another libspotify version, it is possible hard float was my previous OS. As far as config goes, I would assume ruby 2.0 was installed, but nothing else. |
So i can use it with libspotify 12.1.103 beta ? I tried to install this by hand and installed the spottily gem (raspberry branch) but got this:
Do i have to install any libspotify gem too? i could not find any raspberry branch here? |
I took a look at it today, and I believe this was my setup:
Yes. The raspberry pi branch of spotify have removed the hard coded version check. It will no longer crash on boot with a wrong libspotify version error. |
Alright. Can run the examples now. Another Problem was line 1 in the examples "support.rb" require "bundler/setup" with this line libspotify cannot be found. I commented it out and now libspotify and spotify gem runs until a track is played. Problem now ist: Track is played (dots are running in example_audio_stream.rb) BUT if have NO Audio. Log:
Any ideas? |
Yeah, I noticed the problem with bundler now too. I just released a new version of libspotify with support for hard float in the gem, so one should not need to install libspotify manually. Unfortunately, there is a bug in rubygems, so it does not install the arm-linux release of libspotify gem, and there is (probably) a bug in bundler, so it ignores the installed libspotify gem with arm-linux platform, and installs pure ruby version. Like you noticed, the fix is manual install of libspotify gem with Regarding your problem with no audio, I ran into it too and it is solvable. Here are the issues:
I solved it by doing these steps: git clone https://github.com/Burgestrand/plaything
cd plaything
git checkout raspberry-pi
rake build # build raspberry-pi gem
gem install pkg/plaything-1.1.1.gem # install raspberry-pi-specific gem globally After that, you should be able to run the examples, assuming that:
After all of these steps, I could play a sound file through HDMI speakers. I had slight a little lag like two times during the entire song, but it was mostly okay. |
works. Thanks for your good support!!! I will enjoy your gem now! |
Nice! Sorry about the issues. Raspberry PI is a tricky platform, because not many people use it. I want to change audio to be better though, and so that raspberry pi should be able to play audio too without crazy workarounds. |
would it possible to use a USB Soundcard? Do i have to write my own driver for this? |
I don't know. I don't have a USB soundcard to try with. Plaything will use the default sound output device for playback by default. I think if you are able to change default device globally on your raspberry pi, plaything should use this new device. |
Plaything uses alcOpenDevice: https://github.com/Burgestrand/plaything/blob/master/lib/plaything.rb#L36, and passes in NULL. This is the line that needs to change if you want to change the device through code. |
works too. I think changing the device index in plaything would be possible too, but didn't try. Reason for using the USB Soundcard is that this prevents me from having this ugly static noise which the internal raspberry sound has. |
After managing to install the spottily gem (see #27) i am now able to play Musik with the delivered examples.
Unfortunaly it is very laggy, The Playback stops every few seconds and starts after further 2-3 seconds again.
"top" shows ~90% cpu-usage by ruby-process. Any hints?
The text was updated successfully, but these errors were encountered: