fix(cast): cleanup Chromecast connection on app exit

This commit is contained in:
vicrodh committed 2026-01-26 11:01:14 -06:00
1 parent 1384a1d276
commit 2f4b79f1bf
1 file changed
+14
+14
View File
@@ -390,6 +390,20 @@ pub fn run() {
log::info!("Close to tray: hiding window instead of closing"); log::info!("Close to tray: hiding window instead of closing");
let _ = window.hide(); let _ = window.hide();
api.prevent_close(); 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::<cast::CastState>() {
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");
} }
} }
}) })