diff --git a/media/audio/win/audio_session_creation_observer_win.cc b/media/audio/win/audio_session_creation_observer_win.cc --- a/media/audio/win/audio_session_creation_observer_win.cc +++ b/media/audio/win/audio_session_creation_observer_win.cc @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include + #include "media/audio/win/audio_session_creation_observer_win.h" #include @@ -37,6 +39,10 @@ HRESULT AudioSessionCreationObserverWin::QueryInterface(REFIID iid, HRESULT AudioSessionCreationObserverWin::OnSessionCreated( IAudioSessionControl* session) { + // POC instrumentation: widen the race window so the UI thread can free + // |this| between the MM thread loading the vtable and dereferencing + // session_created_cb_. Remove for real-world timing. + ::Sleep(50); session_created_cb_.Run(); return S_OK; } diff --git a/media/audio/win/audio_ducker_win.cc b/media/audio/win/audio_ducker_win.cc --- a/media/audio/win/audio_ducker_win.cc +++ b/media/audio/win/audio_ducker_win.cc @@ -106,6 +106,9 @@ AudioDuckerWin::AudioDuckerWin(ShouldDuckProcessCallback callback) AudioDuckerWin::~AudioDuckerWin() { StopDuckingOtherWindowsApplications(); + // POC instrumentation: force the std::unique_ptr free now (member dtor would + // do this anyway one line later) so ASan poisons the slot before the sleeping + // MM-thread callback resumes. + session_creation_observer_.reset(); } void AudioDuckerWin::StartDuckingOtherWindowsApplications() {