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
SpectrumTapfromAudioService. - 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-spectrumevents atSTREAM_INTERVAL_MScadence. - Automatically exits when event emission fails (for example, when window closes).