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:
@@ -2,7 +2,7 @@
|
|||||||
-- ============================================================================
|
-- ============================================================================
|
||||||
-- 1. Configuration & Constants
|
-- 1. Configuration & Constants
|
||||||
-- ============================================================================
|
-- ============================================================================
|
||||||
local APP_VERSION_TEXT = "v1.0.17"
|
local APP_VERSION_TEXT = "v1.0.18"
|
||||||
|
|
||||||
local CONFIG = {
|
local CONFIG = {
|
||||||
CLOUD_URL = "ws://stabadmin.fse-media.group",
|
CLOUD_URL = "ws://stabadmin.fse-media.group",
|
||||||
@@ -14,7 +14,7 @@ local CONFIG = {
|
|||||||
DISK_AUDIO_STATION = "disk/Audio/Station/",
|
DISK_AUDIO_STATION = "disk/Audio/Station/",
|
||||||
STATION_IDENTITY_FILE = "station_identity.cfg",
|
STATION_IDENTITY_FILE = "station_identity.cfg",
|
||||||
AUDIO_VOLUME = 3,
|
AUDIO_VOLUME = 3,
|
||||||
AUDIO_STREAM_PREROLL_CHUNKS = 2,
|
AUDIO_STREAM_PREROLL_CHUNKS = 5,
|
||||||
DEBUG = true
|
DEBUG = true
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1611,6 +1611,12 @@ function Audio.playWavStreamItem(item)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local playSeq = State.interruptSeq
|
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 source = item.audioData
|
||||||
local streamObj = nil
|
local streamObj = nil
|
||||||
|
|
||||||
@@ -1663,12 +1669,7 @@ function Audio.playWavStreamItem(item)
|
|||||||
tonumber(meta and meta.channels) or 0,
|
tonumber(meta and meta.channels) or 0,
|
||||||
tonumber(meta and meta.bitsPerSample) or 0
|
tonumber(meta and meta.bitsPerSample) or 0
|
||||||
))
|
))
|
||||||
local playOk
|
local playOk = playChunkOnSpeakers(samples, CONFIG.AUDIO_VOLUME, playSeq, false)
|
||||||
if #Peripherals.speakers > 1 then
|
|
||||||
playOk = queueSamplesSynchronized(samples, CONFIG.AUDIO_VOLUME, playSeq)
|
|
||||||
else
|
|
||||||
playOk = playChunkOnSpeakers(samples, CONFIG.AUDIO_VOLUME, playSeq, false)
|
|
||||||
end
|
|
||||||
if not playOk then
|
if not playOk then
|
||||||
Audio.stop("current")
|
Audio.stop("current")
|
||||||
return
|
return
|
||||||
|
|||||||
Reference in New Issue
Block a user