1. 移除 server.js 生成的每个音频分片携带的 44 字节 WAV 头,防止将其作为音频样本解码导致每 0.25 秒出现点击声 ('哒')。 2. 优化 playAudio 队列满时的轮询机制,从原先阻塞等待 speaker_audio_empty(会导致扬声器饥饿)改为使用 0.05 秒的定时器定期尝试,以保持缓冲区处于满载状态。 3. 同步修复了 station_broadcast-warning.lua 中潜在的相同轮询饥饿问题。 4. 版本号递增至 v1.0.62。
91 lines
2.3 KiB
Lua
91 lines
2.3 KiB
Lua
--[[
|
|
Author: HenryDu8133 813367384@qq.com
|
|
Date: 2026-05-31 00:12:30
|
|
LastEditors: HenryDu8133 813367384@qq.com
|
|
LastEditTime: 2026-08-16 11:28:02
|
|
FilePath: \StationBroadcastDisplayCN\install_station_broadcast.lua
|
|
Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
|
|
--]]
|
|
local STATION_BROADCAST_URL = "https://gitea.fse-media.group/Henry_Du/CC-StationBroadcast/raw/branch/main/station_broadcast.lua"
|
|
local UPDATE_SCRIPT_URL = "https://gitea.fse-media.group/Henry_Du/CC-StationBroadcast/raw/branch/main/update_station_broadcast.lua"
|
|
|
|
local function fetch(url)
|
|
if not http then
|
|
return nil, "HTTP API unavailable"
|
|
end
|
|
|
|
if http.checkURL then
|
|
local ok, err = http.checkURL(url)
|
|
if not ok then
|
|
return nil, err or "URL blocked"
|
|
end
|
|
end
|
|
|
|
local res, err = http.get(url)
|
|
if not res then
|
|
return nil, err or "request failed"
|
|
end
|
|
|
|
local body = res.readAll()
|
|
res.close()
|
|
|
|
if type(body) ~= "string" or #body == 0 then
|
|
return nil, "empty response"
|
|
end
|
|
|
|
return body
|
|
end
|
|
|
|
local function writeFile(path, content)
|
|
local dir = fs.getDir(path)
|
|
if dir and dir ~= "" and not fs.exists(dir) then
|
|
fs.makeDir(dir)
|
|
end
|
|
|
|
local f = fs.open(path, "w")
|
|
if not f then
|
|
return nil, "cannot open " .. path
|
|
end
|
|
|
|
f.write(content)
|
|
f.close()
|
|
return true
|
|
end
|
|
|
|
local function downloadTo(url, path)
|
|
write(("Downloading %s... "):format(path))
|
|
local body, err = fetch(url)
|
|
if not body then
|
|
print("FAILED")
|
|
print(err)
|
|
return false
|
|
end
|
|
|
|
local ok, werr = writeFile(path, body)
|
|
if not ok then
|
|
print("FAILED")
|
|
print(werr)
|
|
return false
|
|
end
|
|
|
|
print("OK")
|
|
return true
|
|
end
|
|
|
|
local targets = {
|
|
{ url = STATION_BROADCAST_URL, path = shell.resolve("/startup") },
|
|
{ url = UPDATE_SCRIPT_URL, path = shell.resolve("/update_station_broadcast.lua") }
|
|
}
|
|
|
|
for _, t in ipairs(targets) do
|
|
local ok = downloadTo(t.url, t.path)
|
|
if not ok then
|
|
print("Install aborted.")
|
|
return
|
|
end
|
|
end
|
|
|
|
print("Install complete.")
|
|
print("Update helper installed as /update_station_broadcast.lua")
|
|
print("Run 'reboot' to start StationBroadcast on boot.")
|