Issues

Issue #491 wontfix

Adding buffer size to love.audio.newSource

hahawoo
created an issue

I propose that love.audio.newSource accept a buffer size as second argument, to let lövers balance the time-memory tradeoff without having to create an intermediate Decoder.

love.audio.newSource("music.ogg", 4096)

The Source is implicitly of type "stream", because (if my understanding is correct) the buffer size is the size of the buffer used when streaming.

I think this could be implemented by this change to audio.lua:

function love.audio.newSource(a, b)
    if type(a) == "string" then
        a = love.filesystem.newFile(a)
    end
    if type(a) == "userdata" then
        if a:typeOf("File") then
            if type(b) == "number" then
                a = love.sound.newDecoder(a, b)
            else
                a = love.sound.newDecoder(a)
            end
        end

        if a:typeOf("Decoder") then
            if b == "static" then
                a = love.sound.newSoundData(a)
            end
            return love.audio.newSource1(a)
        end
        if a:typeOf("SoundData") then
            return love.audio.newSource1(a)
        end
    end
    error("No matching overload")
end

Edit: I think I obscured what I was trying to say originally by mentioning something which was more of a documentation issue, and I was also a bit confused about how Decoders are used (and please say if I still am). I've refined this issue, and I hope no one minds if I reopen it.

Comments (4)

  1. Log in to comment