1. Anders Ruud
  2. love
  3. Issues


Issue #319 resolved

Improving efficiency of static Sources

created an issue

Currently, every static Source has its own OpenAL buffer. Creating static Sources from the same SoundData spawns multiple OpenAL buffers with the same uncompressed data. Creating a lövely solution to this is probably something for the audio module overhaul, as it most likely invovles rewriting the buffer handling.

There's no workaround in lover land for this. Maybe LÖVE could give the option to create multiple sources to the same buffer until the overhaul. This still involves modifying the buffer handling, but it might be less code.

It could look like this: \\ {{{


s1, s2, s3, s4, s5 = love.audio.newSource("meow.ogg", "static", 5) }}}

Comments (6)

  1. Alex Szpakowski

    Maybe 'cloning' of Sources could be a thing?

    source2 = love.audio.newSource(source1) or source2 = source1:clone() or something.

    Cloned Sources would inherit the settable parameters of the original Source (position, volume, etc.) and they would share the same OpenAL buffer if the original Source is static.

    They would be initialized as stopped though, instead of keeping the play-state of the original Source.

    I'm not 100% sold on my idea though - I don't think it's completely apparent why cloning is useful without explanation, and for reducing the duplication of static buffer data it feels in some ways like it's exposing an implementation detail instead of making things more streamlined.

  2. Alex Szpakowski

    Using the AL_EXT_STATIC_BUFFER extension it would be trivial to have multiple static Sources all backed by a single SoundData, however the SoundData could be modified at any time by the lover so that's bad.

  3. Alex Szpakowski

    Added Source:clone() and love.audio.newSource(source): creates a new (stopped) Source which has all of the settable state of the original. Static sources don’t duplicate their OpenAL data buffer when cloned (resolves issue #319). Cloned streaming sources also clone the original Decoder.

    → <<cset cbf127142b2a>>

    The additional argument to love.audio.newSource Boolsheet proposes could still be done as well, if people want.

  4. hahawoo

    Do source:clone() and love.audio.newSource(source) do the same thing?

    If so I think one of them should be removed, because I don't think there should be more than one way of doing the exact same thing, like Source playback methods (#483).

    Maybe Source:clone() would be more convenient/descriptive than love.audio.newSource(source)... maybe?

  5. Log in to comment