Queueable sources don't always free buffers
Posted: Sat Dec 05, 2020 11:52 pm
I'm looking to create a queueable audio source with the least amount of delay that I can possibly get away with before stuttering occurs.
This is my main.lua:
And this is an excerpt from the print output:
Assuming I haven't screwed up the math, there should be, according to the delta time, roughly 6 or 7 buffers used and freed up at any given update call, but what we see instead is that either all of the buffers are free or none of them are. Can anyone explain to me what the reason is behind that behavior? Also, is there any way to have it distribute the work more evenly between update calls?
This is my main.lua:
Code: Select all
size ,samplerate ,bitdepth ,channels ,buffers =
128 ,48000 ,16 ,1 ,8
bufs_per_ms = (samplerate / 1000) / size
function love.load()
sdata = love.sound.newSoundData(size, samplerate, bitdepth, channels)
source = love.audio.newQueueableSource(samplerate, bitdepth, channels, buffers)
end
function love.update(dt)
dt = dt * 1000
local bufs = dt * bufs_per_ms
local count = source:getFreeBufferCount()
print(
string.format('%.2f', dt)..' ms'
..' expected: '..string.format('%.2f', bufs)
..' got: '..(count>0 and count or 'none')
)
for _=1,count do
source:queue(sdata)
source:play()
end
end
Code: Select all
17.00 ms expected: 6.37 got: 8
16.43 ms expected: 6.16 got: 8
16.60 ms expected: 6.22 got: none
16.67 ms expected: 6.25 got: 8
16.83 ms expected: 6.31 got: 8
16.62 ms expected: 6.23 got: 8
16.66 ms expected: 6.25 got: none
16.63 ms expected: 6.24 got: 8
16.40 ms expected: 6.15 got: 8
16.98 ms expected: 6.37 got: 8
16.60 ms expected: 6.22 got: none
16.48 ms expected: 6.18 got: 8