Restart audio pipeline for fresh stream header

This commit is contained in:
Smittix
2026-02-04 11:04:43 +00:00
parent d59ebfb270
commit d64b351aef
2 changed files with 11 additions and 4 deletions
+7
View File
@@ -939,6 +939,13 @@ def audio_probe() -> Response:
@listening_post_bp.route('/audio/stream') @listening_post_bp.route('/audio/stream')
def stream_audio() -> Response: def stream_audio() -> Response:
"""Stream WAV audio.""" """Stream WAV audio."""
# Optionally restart pipeline so the stream starts with a fresh header
if request.args.get('fresh') == '1' and audio_running:
try:
_start_audio_stream(audio_frequency or 0.0, audio_modulation or 'fm')
except Exception as e:
logger.error(f"Audio stream restart failed: {e}")
# Wait for audio to be ready (up to 2 seconds for modulation/squelch changes) # Wait for audio to be ready (up to 2 seconds for modulation/squelch changes)
for _ in range(40): for _ in range(40):
if audio_running and audio_process: if audio_running and audio_process:
+1 -1
View File
@@ -2121,7 +2121,7 @@ async function _startDirectListenInternal() {
await new Promise(r => setTimeout(r, 300)); await new Promise(r => setTimeout(r, 300));
// Connect to new stream // Connect to new stream
const streamUrl = `/listening/audio/stream?t=${Date.now()}`; const streamUrl = `/listening/audio/stream?fresh=1&t=${Date.now()}`;
console.log('[LISTEN] Connecting to stream:', streamUrl); console.log('[LISTEN] Connecting to stream:', streamUrl);
audioPlayer.src = streamUrl; audioPlayer.src = streamUrl;
audioPlayer.preload = 'auto'; audioPlayer.preload = 'auto';