diff --git a/routes/listening_post.py b/routes/listening_post.py index a094fbd..46c0943 100644 --- a/routes/listening_post.py +++ b/routes/listening_post.py @@ -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 diff --git a/static/js/modes/listening-post.js b/static/js/modes/listening-post.js index 2f893ec..1e8c19f 100644 --- a/static/js/modes/listening-post.js +++ b/static/js/modes/listening-post.js @@ -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';