Issues

Issue #5 resolved

Audio playback is trivial at best

Anonymous created an issue

There are //many// times when LÖVE decides to decode audio for about half a second, and then roll over and die. Literally, of course.

Comments (14)

  1. Bill Meltsner

    More information, please. Specifically, what audio format(s) is this a problem with? When you say "roll over and die" are you referring to playback stopping or LÖVE crashing or something else? When the audio stops playing, does Source:isStopped() return true?

  2. FelipeBudinich

    I have the same issue, under windows xp, love 0.6.2. And it happens with .mp3 files and .ogg files very often, and with smaller .mod files it is less frequent.

    I'll use Source:isStopped() to see if it returns true, and i'll be back.

    PS: Yes it does return true.

  3. Bart van Strien

    Rude formulated a thought that it might be a feeding issue in love.sound, but after having poked around it many times it seems the issue rather lies in love.audio, further investigation is still needed.

  4. vrld

    It seems as if streaming ogg files that are shorther than one second does not work either. Ruling out feeding issues in love.sound this suggests it may be an issue with physfs.

  5. vrld

    Damnit, wrong button. Again:

    I think i found the problem. It is a race condition between Pool::play()/Source::play() vs Pool::update().

    In Source::play(), Source::valid is set to the return value of Pool::play(), which is only false if there are no more free Sources. As Pool::play() operates on shared structures (playing and available), it locks a mutex to prevent Pool::update() to access them too. Before leaving, Pool::play() unlocks the mutex as it should. At this point Source::valid is still false.

    Then Pool::update() takes over, checking the playing container for stopped sources using Source::isStopped(). Here's the catch:

    Source::isStopped() depends on the value of Source::valid - it always returns true if Source::valid is false, which it is at this point. Pool::update() then proceeds to delete the source from the playing container and add it to the available queue, preventing more streaming in future calls of Pool::update().

    To prevent this the quick and hackish way:

    Add to Source class: friend class Pool;

    Add to Pool::play(), before UNLOCK(mutex);: source->valid = ok;

  6. Log in to comment