Skip to main content

start_live_spectrum_stream

Function start_live_spectrum_stream 

Source
pub fn start_live_spectrum_stream(
    window: Window,
    audio_service: State<'_, Mutex<AudioService>>,
    stream_state: State<'_, SpectrumStreamState>,
) -> Result<(), String>
Expand description

Starts (or restarts) push-based live spectrum streaming for the calling window.

Behavior:

  • Captures the current shared SpectrumTap from AudioService.
  • Signals any previously running stream task to shut down using that task’s own cancellation flag, then replaces it.
  • Spawns a background loop that analyzes the tap and emits live-spectrum events at STREAM_INTERVAL_MS cadence.
  • Automatically exits when event emission fails (for example, when window closes).