Restart audio pipeline for fresh stream header

This commit is contained in:
Smittix
2026-02-04 11:04:43 +00:00
parent 4bd7077d64
commit 82ad784fcb
2 changed files with 11 additions and 4 deletions

View File

@@ -936,10 +936,17 @@ def audio_probe() -> Response:
return jsonify({'status': 'ok', 'bytes': size})
@listening_post_bp.route('/audio/stream')
def stream_audio() -> Response:
@listening_post_bp.route('/audio/stream')
def stream_audio() -> Response:
"""Stream WAV audio."""
# Wait for audio to be ready (up to 2 seconds for modulation/squelch changes)
# 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)
for _ in range(40):
if audio_running and audio_process:
break

View File

@@ -2121,7 +2121,7 @@ async function _startDirectListenInternal() {
await new Promise(r => setTimeout(r, 300));
// 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);
audioPlayer.src = streamUrl;
audioPlayer.preload = 'auto';