Perf: fix audio playback stuttering by increasing pre-buffer to 5 chunks and optimizing multi-speaker synchronization without forced gaps

This commit is contained in:
2026-08-01 23:19:37 +08:00
parent 944f00f521
commit 66ce214f51
+9 -8
View File
@@ -2,7 +2,7 @@
-- ============================================================================
-- 1. Configuration & Constants
-- ============================================================================
local APP_VERSION_TEXT = "v1.0.17"
local APP_VERSION_TEXT = "v1.0.18"
local CONFIG = {
CLOUD_URL = "ws://stabadmin.fse-media.group",
@@ -14,7 +14,7 @@ local CONFIG = {
DISK_AUDIO_STATION = "disk/Audio/Station/",
STATION_IDENTITY_FILE = "station_identity.cfg",
AUDIO_VOLUME = 3,
AUDIO_STREAM_PREROLL_CHUNKS = 2,
AUDIO_STREAM_PREROLL_CHUNKS = 5,
DEBUG = true
}
@@ -1611,6 +1611,12 @@ function Audio.playWavStreamItem(item)
end
local playSeq = State.interruptSeq
-- Ensure all speakers are completely empty and synced before starting the new stream
if not waitForNativeSpeakersEmpty(Peripherals.speakers, playSeq) then
return
end
local source = item.audioData
local streamObj = nil
@@ -1663,12 +1669,7 @@ function Audio.playWavStreamItem(item)
tonumber(meta and meta.channels) or 0,
tonumber(meta and meta.bitsPerSample) or 0
))
local playOk
if #Peripherals.speakers > 1 then
playOk = queueSamplesSynchronized(samples, CONFIG.AUDIO_VOLUME, playSeq)
else
playOk = playChunkOnSpeakers(samples, CONFIG.AUDIO_VOLUME, playSeq, false)
end
local playOk = playChunkOnSpeakers(samples, CONFIG.AUDIO_VOLUME, playSeq, false)
if not playOk then
Audio.stop("current")
return