From 2f4b79f1bfc3f5a70b1f70439f36fef8ec193369 Mon Sep 17 00:00:00 2001 From: vicrodh <103399283+vicrodh@users.noreply.github.com> Date: Mon, 26 Jan 2026 11:01:14 -0600 Subject: [PATCH] fix(cast): cleanup Chromecast connection on app exit --- src-tauri/src/lib.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs index d1c50ebb7..bdb822ae8 100644 --- a/src-tauri/src/lib.rs +++ b/src-tauri/src/lib.rs @@ -390,6 +390,20 @@ pub fn run() { log::info!("Close to tray: hiding window instead of closing"); let _ = window.hide(); api.prevent_close(); + } else { + // Cleanup cast devices on actual close + log::info!("App closing: cleaning up cast devices"); + + // Disconnect Chromecast if connected (sends message through channel) + if let Some(cast_state) = window.app_handle().try_state::() { + log::info!("Disconnecting Chromecast on app exit"); + cast_state.chromecast.disconnect(); + } + + // Note: DLNA connection will be dropped when the app exits, + // which will naturally close the connection. The tokio Mutex + // prevents us from synchronously stopping playback here. + log::info!("DLNA connection will be cleaned up on drop"); } } })