Burgestrand / Hallon

Hallon is currently **UNMAINTAINED**.
http://rdoc.info/github/Burgestrand/Hallon/master/frames
134 stars 12 forks source link

High CPU usage during audio playback on Raspberry Pi 512MB #140

Open jakemauer opened 11 years ago

jakemauer commented 11 years ago

Hi Kim,

First of all, the amount of work and community engagement you've undertaken with your Spotify projects is inspiring. Thank you so much for the work you've done.

I'm attempting to build a Raspberry Pi based player and while I've got basic audio playback happening, my CPU usage is pegged. I've overclocked my CPU to 900mhz and that helps, but not enough. It hovers between 90-100% usage. Have you noticed the same thing on your Pi?

I'm running the Rev. B with 512MB of ram, video ram split is set at 64mb. Processor is OC'd to 900Mhz. I'm running Ruby 1.9.3p194 and libspotify armv5. I can get you versions of additional libraries and binaries if that helps.

I'd be happy to run any tests or generally experiment to find solutions but I don't know where to start. I was thrilled just to get audio playback working!

I assume things will improve once we can switch to hard float Wheezy, but I understand your reservations for waiting.

Anyway, thanks again for all your work.

Burgestrand commented 11 years ago

I’ve never tried audio playback on the raspberry pi, but I’m glad it works on some level! I find it strange that it should be so demanding for the CPU, but I’ll take a look on my own pi when I get the chance to see if I can find the reason to why that might be.

I’ve also begun writing on a new audio driver, that is way less over engineered than the current one, and it does not need Hallon to to work around the convoluted way of using it: https://github.com/Burgestrand/plaything (no gem released yet, and it’s merely at an experimental stage at the moment) — I’m also working on an example on how to use it with only the spotify gem (and not Hallon) here: https://gist.github.com/Burgestrand/44628c72f08a412c0e44. My plan is to switch over any development of the audio playback to this new gem, instead of hallon-openal, but there is no timeframe planned. However, depending on your use-case perhaps this way both performs better and is easier to work with. Keep in mind it’s not entirely stable in the audio playback, as audio might stop playing and not start again. Still trying to figure out what numbers libspotify want from me.

Anyhow, I’ll make sure to take a look.

swerner commented 11 years ago

Interesting, I hadn't thought to check the cpu load while playing music. I'm working on a spotify+raspberry pi project too. I'll check it out tonight or tomorrow and report back if I'm seeing the same things.

On Fri, Mar 22, 2013 at 5:36 AM, Kim Burgestrand notifications@github.com wrote:

I’ve never tried audio playback on the raspberry pi, but I’m glad it works on some level! I find it strange that it should be so demanding for the CPU, but I’ll take a look on my own pi when I get the chance to see if I can find the reason to why that might be. I’ve also begun writing on a new audio driver, that is way less over engineered than the current one, and it does not need Hallon to to work around the convoluted way of using it: https://github.com/Burgestrand/plaything — I’m also working on an example on how to use it with only the spotify gem (and not Hallon) here: https://gist.github.com/Burgestrand/44628c72f08a412c0e44. My plan is to switch over any development of the audio playback to this new gem, instead of the old, but there is no timeframe planned. However, depending on your use-case perhaps this way both performs better and is easier to work with. Keep in mind it’s not entirely stable in the audio playback, as audio might stop playing and not start again. Still trying to figure out what numbers libspotify want from me.

Anyhow, I’ll make sure to take a look.

Reply to this email directly or view it on GitHub: https://github.com/Burgestrand/Hallon/issues/140#issuecomment-15287931

Burgestrand commented 11 years ago

I have not managed to take a look yet, and it will be until (at the very least) tuesday before I’ll be able to because of easter holidays coming up in sweden.

With that said, I’ve been focusing more and more on my alternative way of playing audio. I’ve released a gem named plaything, that is severely lacking in documentation. There’ll be another point release soon with some bug fixes and JRuby support. Together with the example code now in the spotify repository, playing audio should be much less stressful on the CPU. I should note there’ll be a point release for spotify soon as well, to support JRuby better (and Rubinius as well, but I fear they might have a bug related to FFI and garbage collection).

So, if you want to play audio with the spotify gem, I would highly suggest you take a look at the example code in the spotify repository. My intention is to deprecate the hallon-openal gem. I suppose an implementation using plaything in hallon is not completely out of the question.

jakemauer commented 11 years ago

Hey Kim,

Sorry for the delay, I haven't had a chance to try your script on the Pi yet. I'll hopefully get a chance this weekend and report back.

Burgestrand commented 11 years ago

There is no hurry. I have yet to try the hallon-openal gem on raspberry pi myself, nor the plaything audio playback :).

Burgestrand commented 11 years ago

I did try plaything now on the raspberry pi. It does not play audio properly, because (for a reason I have yet to research) audio is not delivered fast enough to play it back. The current gem release does not work on raspberry pi either, you’ll need to use the version from github at https://github.com/Burgestrand/plaything.

I did notice that during audio playback the CPU would be pretty high, and there would be a lot of audio dropout because of audio streaming not being able to keep up with playback. It appeared that while audio was not being played back, CPU would reside around 20-40% usage, but once audio was playing it would soar up close to 100%.

I suspect this will be tricky to solve, but I want to be able to play sound on the raspberry pi, mainly because it should be cool and I don’t see why it shouldn’t be possible.