Refactor AudioPlayer for improved native playback handling and debugging

- Introduced a stop flag mechanism to manage audio playback more effectively.
- Enhanced native playback logic to ensure proper stopping of existing streams before starting new playback.
- Updated error handling and logging for better visibility during playback operations.
- Refactored audio output handling in Rust to support stopping playback and outputting silence when required.
- Improved the integration of native playback with WaveSurfer for seamless audio visualization.
This commit is contained in:
Jamie Pine
2026-01-27 16:25:38 -08:00
parent 7f18c09628
commit f7cb219f6d
3 changed files with 274 additions and 85 deletions
+9 -1
View File
@@ -385,6 +385,13 @@ async fn play_audio_to_devices(
state.play_audio_to_devices(audio_data, device_ids).await
}
#[command]
fn stop_audio_playback(
state: State<'_, audio_output::AudioOutputState>,
) -> Result<(), String> {
state.stop_all_playback()
}
#[cfg_attr(mobile, tauri::mobile_entry_point)]
pub fn run() {
tauri::Builder::default()
@@ -443,7 +450,8 @@ pub fn run() {
stop_system_audio_capture,
is_system_audio_supported,
list_audio_output_devices,
play_audio_to_devices
play_audio_to_devices,
stop_audio_playback
])
.on_window_event(|window, event| {
if let WindowEvent::CloseRequested { api, .. } = event {