fix(server): 完善列车接近音频的处理与日志记录
新增列车接近音频入队和构建失败的日志输出 调整音频任务优先级为1,中断模式改为ifLower 修复音频构建为空时的静默失败问题
This commit is contained in:
@@ -2027,18 +2027,21 @@ function handleTrainApproaching(ws, data) {
|
|||||||
const audioId = `approaching-${stationCode}-${Date.now()}`;
|
const audioId = `approaching-${stationCode}-${Date.now()}`;
|
||||||
const built = buildSequenceWavFile(seq);
|
const built = buildSequenceWavFile(seq);
|
||||||
if (built) {
|
if (built) {
|
||||||
|
log('INFO', `Pre-arrival audio queued for ${stationName}: ${audioId} (${built.durationSec.toFixed(2)}s)`);
|
||||||
enqueueStationAudioTask(stationName, ws, {
|
enqueueStationAudioTask(stationName, ws, {
|
||||||
audioFormat: built.audioFormat,
|
audioFormat: built.audioFormat,
|
||||||
sourcePath: built.sourcePath,
|
sourcePath: built.sourcePath,
|
||||||
streamUrl: built.streamUrl,
|
streamUrl: built.streamUrl,
|
||||||
durationSec: built.durationSec,
|
durationSec: built.durationSec,
|
||||||
priority: 0,
|
priority: 1,
|
||||||
interruptMode: 'none',
|
interruptMode: 'ifLower',
|
||||||
source: 'train_approaching',
|
source: 'train_approaching',
|
||||||
audioId,
|
audioId,
|
||||||
consoleStreamStart: { type: 'stream_start', station: stationName, seq, streamName: getStationStreamName(stationName), hlsUrl: getStationHlsUrl(getStationStreamName(stationName)) },
|
consoleStreamStart: { type: 'stream_start', station: stationName, seq, streamName: getStationStreamName(stationName), hlsUrl: getStationHlsUrl(getStationStreamName(stationName)) },
|
||||||
consoleStreamEnd: { type: 'stream_end', station: stationName }
|
consoleStreamEnd: { type: 'stream_end', station: stationName }
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
|
log('WARN', `Pre-arrival audio build returned empty for ${stationName}: ${audioId}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+15
-10
@@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
-- 1. Configuration & Constants
|
-- 1. Configuration & Constants
|
||||||
local APP_VERSION_TEXT = "v1.0.47"
|
local APP_VERSION_TEXT = "v1.0.48"
|
||||||
|
|
||||||
local CONFIG = {
|
local CONFIG = {
|
||||||
CLOUD_URL = "ws://stabadmin.fse-media.group",
|
CLOUD_URL = "ws://stabadmin.fse-media.group",
|
||||||
@@ -2774,22 +2774,27 @@ function Main.loop()
|
|||||||
end
|
end
|
||||||
|
|
||||||
if tName and etaStr then
|
if tName and etaStr then
|
||||||
local announceKey = tName .. "_" .. dest
|
local announceKey = normalizeUpcomingKey(tName, dest)
|
||||||
|
|
||||||
local etaSeconds = -1
|
local etaSeconds = -1
|
||||||
local isNow = string.find(etaStr, "现在") or string.find(etaStr, "0")
|
local isNow = string.find(etaStr, "现在")
|
||||||
|
|
||||||
if isNow then
|
if isNow then
|
||||||
etaSeconds = 0
|
etaSeconds = 0
|
||||||
else
|
else
|
||||||
local num, unit = string.match(etaStr, "(%d+)%s*(.*)")
|
local mm, ss = string.match(etaStr, "^(%d+)%s*:%s*(%d+)%s*$")
|
||||||
if num then
|
if mm and ss then
|
||||||
num = tonumber(num)
|
etaSeconds = tonumber(mm) * 60 + tonumber(ss)
|
||||||
|
else
|
||||||
|
local num, unit = string.match(etaStr, "(%d+)%s*(.*)")
|
||||||
|
if num then
|
||||||
|
num = tonumber(num)
|
||||||
|
|
||||||
if string.find(unit, "秒") or string.find(unit, "s") or string.find(unit, "sec") or (unit == "??" and num > 10) then
|
if string.find(unit, "秒") or string.find(unit, "s") or string.find(unit, "sec") or (unit == "??" and num > 10) then
|
||||||
etaSeconds = num
|
etaSeconds = num
|
||||||
else
|
else
|
||||||
etaSeconds = num * 60
|
etaSeconds = num * 60
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user