updated
This commit is contained in:
@@ -30,7 +30,6 @@ end
|
||||
-- end
|
||||
-- end
|
||||
-- end
|
||||
|
||||
local function playSpeaker(speaker, input)
|
||||
local decoder = require("cc.audio.dfpwm").make_decoder()
|
||||
local decoded = decoder(input)
|
||||
@@ -42,17 +41,19 @@ end
|
||||
local function playSound(speakers, fileName)
|
||||
local fileStream = getFileName(fileName)
|
||||
local values = io.lines(fileStream, 16 * 1024)
|
||||
|
||||
for input in values do
|
||||
print("playing audio...")
|
||||
|
||||
-- Create parallel tasks, each with its own decoder instance
|
||||
local tasks = {}
|
||||
for _, speaker in ipairs(speakers) do
|
||||
table.insert(tasks, function()
|
||||
-- each speaker needs its own decoder for the same input chunk
|
||||
playSpeaker(speaker, input)
|
||||
end)
|
||||
end
|
||||
|
||||
-- Execute all in parallel
|
||||
parallel.waitForAll(table.unpack(tasks))
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user