fix(station): prefer native speaker.playAudio for decoded chunks
Bump the station build to v1.0.3 and send decoded WAV samples through each speaker's native playAudio path before falling back to controller.playAudioAll, with logs to show which output path was used.
This commit is contained in:
+34
-21
@@ -2,7 +2,7 @@
|
|||||||
-- ============================================================================
|
-- ============================================================================
|
||||||
-- 1. Configuration & Constants
|
-- 1. Configuration & Constants
|
||||||
-- ============================================================================
|
-- ============================================================================
|
||||||
local APP_VERSION_TEXT = "v1.0.2"
|
local APP_VERSION_TEXT = "v1.0.3"
|
||||||
|
|
||||||
local CONFIG = {
|
local CONFIG = {
|
||||||
CLOUD_URL = "ws://stabadmin.fse-media.group",
|
CLOUD_URL = "ws://stabadmin.fse-media.group",
|
||||||
@@ -593,8 +593,41 @@ end
|
|||||||
|
|
||||||
local function playChunkOnSpeakers(samples, volume, playSeq)
|
local function playChunkOnSpeakers(samples, volume, playSeq)
|
||||||
if not Peripherals.speakers or #Peripherals.speakers == 0 then return false end
|
if not Peripherals.speakers or #Peripherals.speakers == 0 then return false end
|
||||||
|
local pending = {}
|
||||||
|
for _, sp in ipairs(Peripherals.speakers) do
|
||||||
|
local name = peripheral.getName(sp)
|
||||||
|
if name then pending[name] = sp end
|
||||||
|
end
|
||||||
|
|
||||||
|
local usedNativePath = false
|
||||||
|
while next(pending) do
|
||||||
|
if shouldStop(playSeq) then return false end
|
||||||
|
for name, sp in pairs(pending) do
|
||||||
|
local ok = false
|
||||||
|
pcall(function()
|
||||||
|
if type(sp.playAudio) == "function" then
|
||||||
|
ok = sp.playAudio(samples, volume)
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
if ok then
|
||||||
|
usedNativePath = true
|
||||||
|
pending[name] = nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if next(pending) then
|
||||||
|
local ev = { os.pullEvent() }
|
||||||
|
if ev[1] == "audio_interrupt" and tonumber(ev[2]) and tonumber(ev[2]) >= playSeq then
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if usedNativePath then
|
||||||
|
Utils.log("INFO", string.format("Audio samples queued via native speaker.playAudio: samples=%d", #samples))
|
||||||
|
else
|
||||||
local controller = Peripherals.speakers[1]
|
local controller = Peripherals.speakers[1]
|
||||||
if controller and type(controller.playAudioAll) == "function" then
|
if controller and type(controller.playAudioAll) == "function" then
|
||||||
|
Utils.log("WARN", "Falling back to controller.playAudioAll for decoded samples")
|
||||||
while true do
|
while true do
|
||||||
if shouldStop(playSeq) then return false end
|
if shouldStop(playSeq) then return false end
|
||||||
local ok = false
|
local ok = false
|
||||||
@@ -608,29 +641,9 @@ local function playChunkOnSpeakers(samples, volume, playSeq)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
local pending = {}
|
|
||||||
for _, sp in ipairs(Peripherals.speakers) do
|
|
||||||
local name = peripheral.getName(sp)
|
|
||||||
if name then pending[name] = sp end
|
|
||||||
end
|
|
||||||
|
|
||||||
while next(pending) do
|
|
||||||
if shouldStop(playSeq) then return false end
|
|
||||||
for name, sp in pairs(pending) do
|
|
||||||
local ok = false
|
|
||||||
pcall(function()
|
|
||||||
ok = sp.playAudio(samples, volume)
|
|
||||||
end)
|
|
||||||
if ok then pending[name] = nil end
|
|
||||||
end
|
|
||||||
if next(pending) then
|
|
||||||
local ev = { os.pullEvent() }
|
|
||||||
if ev[1] == "audio_interrupt" and tonumber(ev[2]) and tonumber(ev[2]) >= playSeq then
|
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
local waiting = {}
|
local waiting = {}
|
||||||
for _, sp in ipairs(Peripherals.speakers) do
|
for _, sp in ipairs(Peripherals.speakers) do
|
||||||
|
|||||||
Reference in New Issue
Block a user