Page 1 of 1

Audio glitchy and memory leak?

Posted: Sat Dec 28, 2013 12:15 pm
by LordAndrew
I'm experiencing a weird problem with the audio module of LÖVE. No matter what song I play--regardless of its format--is played in a very glitchy manner (the song stutters and sounds very robotic). LÖVE's memory usage also skyrockets and the program ends up crashing from using up too much memory.

I've tested this on both versions 0.8.0 and 0.9.0 (both clean installs). In one test case I installed LÖVE and in the other I just used the zipped version, but the issue still persists. I have no idea what could be causing this and I'm at a loss. Is there some kind of issue I'm not seeing?

Re: Audio glitchy and memory leak?

Posted: Sat Dec 28, 2013 1:52 pm
by slime
What's the code you're using to test?

Re: Audio glitchy and memory leak?

Posted: Sat Dec 28, 2013 1:58 pm
by LordAndrew
slime wrote:What's the code you're using to test?
It looks like I done goofed. It just hit me why it's happening:

Code: Select all

-- The code I was using.
function love.draw()
  s = love.audio.newSource("test.mp3")
  s:play()
end
Playing a song every tick is probably not a good idea, haha. My bad.

Re: Audio glitchy and memory leak?

Posted: Sat Dec 28, 2013 2:01 pm
by slime
The Source:play() call isn't what's causing the memory issues (although it's generally good to avoid calling that when you don't actually want a Source to start playing.) It's the love.audio.newSource call, which loads a completely unique new Source every time it's called. :)

Re: Audio glitchy and memory leak?

Posted: Sat Dec 28, 2013 7:07 pm
by qubodup
slime wrote:The Source:play() call isn't what's causing the memory issues (although it's generally good to avoid calling that when you don't actually want a Source to start playing.) It's the love.audio.newSource call, which loads a completely unique new Source every time it's called. :)
Clarification: put the love.audio.newSource() line into love.load(). love.draw() gets executed all the time.

Actually you might want to put the :play() line into love.load() for testing as well, unless you want it to repeat all the time.

Re: Audio glitchy and memory leak?

Posted: Sat Dec 28, 2013 7:16 pm
by slime
qubodup wrote:Actually you might want to put the :play() line into love.load() for testing as well, unless you want it to repeat all the time.
If you want it to repeat then you should call Source:setLooping(true) once, and call Source:play() when you want it to start the first time (or if it's paused or stopped at some point and you want to unpause or restart.)

Think of it like music player GUI controls, you click a repeat button and click play, and leave it until you want to change things.

Re: Audio glitchy and memory leak?

Posted: Sun Dec 29, 2013 9:10 am
by bartbes
You don't mash the play button? :crazy: