diff --git a/station_broadcast.lua b/station_broadcast.lua index 61e608a..ff4c5c7 100644 --- a/station_broadcast.lua +++ b/station_broadcast.lua @@ -1432,6 +1432,21 @@ local function playHqAudioItem(item) return controller.speakFileAll(payload, CONFIG.AUDIO_VOLUME) end end) + if not ok then + ok, result = pcall(function() + if format == "hls" and type(controller.speakHLSAll) == "function" then + return controller.speakHLSAll(payload, 3.0) + elseif format == "wav" and type(controller.speakWavAll) == "function" then + return controller.speakWavAll(payload, 3.0) + elseif format == "mp3" and type(controller.speakMp3All) == "function" then + return controller.speakMp3All(payload, 3.0) + elseif format == "ogg" and type(controller.speakOggAll) == "function" then + return controller.speakOggAll(payload, 3.0) + elseif type(controller.speakFileAll) == "function" then + return controller.speakFileAll(payload, 3.0) + end + end) + end if ok and result then called = true end @@ -1457,6 +1472,21 @@ local function playHqAudioItem(item) return sp.speakFile(payload, CONFIG.AUDIO_VOLUME) end end) + if not ok then + ok, result = pcall(function() + if format == "hls" and type(sp.speakHLS) == "function" then + return sp.speakHLS(payload, 3.0) + elseif format == "wav" and type(sp.speakWav) == "function" then + return sp.speakWav(payload, 3.0) + elseif format == "mp3" and type(sp.speakMp3) == "function" then + return sp.speakMp3(payload, 3.0) + elseif format == "ogg" and type(sp.speakOgg) == "function" then + return sp.speakOgg(payload, 3.0) + elseif type(sp.speakFile) == "function" then + return sp.speakFile(payload, 3.0) + end + end) + end if ok and result then called = true end @@ -1489,7 +1519,7 @@ local function pushWavChunkToSpeakers(payload, playSeq) local ok = false local queueSize = -1 local isPlaying = false - pcall(function() + local success, err = pcall(function() ok = controller.speakWavAll(payload, CONFIG.AUDIO_VOLUME) if type(controller.speakQueueSize) == "function" then queueSize = tonumber(controller.speakQueueSize()) or -1 @@ -1498,6 +1528,17 @@ local function pushWavChunkToSpeakers(payload, playSeq) isPlaying = controller.speakIsPlaying() and true or false end end) + if not success then + pcall(function() + ok = controller.speakWavAll(payload, 3.0) + if type(controller.speakQueueSize) == "function" then + queueSize = tonumber(controller.speakQueueSize()) or -1 + end + if type(controller.speakIsPlaying) == "function" then + isPlaying = controller.speakIsPlaying() and true or false + end + end) + end if ok then Utils.log("INFO", string.format("WAV chunk accepted: bytes=%d queue=%d playing=%s", #payload, queueSize, tostring(isPlaying))) return true @@ -1523,11 +1564,18 @@ local function pushWavChunkToSpeakers(payload, playSeq) if shouldStop(playSeq) then return false end for name, sp in pairs(pending) do local ok = false - pcall(function() + local success, err = pcall(function() if type(sp.speakWav) == "function" then ok = sp.speakWav(payload, CONFIG.AUDIO_VOLUME) end end) + if not success then + pcall(function() + if type(sp.speakWav) == "function" then + ok = sp.speakWav(payload, 3.0) + end + end) + end if ok then pending[name] = nil end end if next(pending) then