From 93937533bc00c53311867663a0a3a94d73253862 Mon Sep 17 00:00:00 2001 From: Mike Griese Date: Tue, 16 Nov 2021 09:51:33 -0600 Subject: [PATCH] it's BODGY time --- src/cascadia/TerminalApp/Pane.cpp | 21 +++++++++++++++++++++ src/cascadia/WindowsTerminal/AppHost.cpp | 2 +- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/cascadia/TerminalApp/Pane.cpp b/src/cascadia/TerminalApp/Pane.cpp index 484f70c17..efe515c47 100644 --- a/src/cascadia/TerminalApp/Pane.cpp +++ b/src/cascadia/TerminalApp/Pane.cpp @@ -76,6 +76,27 @@ Pane::Pane(const Profile& profile, const TermControl& control, const bool lastFo try { s_bellPlayer = winrt::Windows::Media::Playback::MediaPlayer(); + if (s_bellPlayer) + { + // BODGY + // + // Manually leak a ref to the MediaPlayer we just instantiated. + // We're doing this just like the way we do in AppHost with the + // App itself. + // + // We have to do this because there's some bug in the OS with + // the way a MediaPlayer gets torn down. At time fo writing (Nov + // 2021), if you search for `remove_SoundLevelChanged` in the OS + // repo, you'll find a pile of bugs. + // + // We tried moving the MediaPlayer singleton up to the + // TerminalPage, but alas, that teardown had the same problem. + // So _whatever_. We'll leak it here. It needs to last the + // lifetim of the app anyways, and it'll get cleaned up when the + // Termnial is closed, so whatever. + winrt::Windows::Media::Playback::MediaPlayer p{ s_bellPlayer }; + ::winrt::detach_abi(p); + } } CATCH_LOG(); } diff --git a/src/cascadia/WindowsTerminal/AppHost.cpp b/src/cascadia/WindowsTerminal/AppHost.cpp index 36d489212..db0951058 100644 --- a/src/cascadia/WindowsTerminal/AppHost.cpp +++ b/src/cascadia/WindowsTerminal/AppHost.cpp @@ -348,7 +348,7 @@ void AppHost::Initialize() _window->SetContent(_logic.GetRoot()); _window->OnAppInitialized(); - // THIS IS A HACK + // BODGY // // We've got a weird crash that happens terribly inconsistently, but pretty // readily on migrie's laptop, only in Debug mode. Apparently, there's some