Index: content/browser/webrtc/webrtc_internals.cc |
diff --git a/content/browser/webrtc/webrtc_internals.cc b/content/browser/webrtc/webrtc_internals.cc |
index 677e7e26c6ea037c1bc73374c7128bd51e126e84..dee0c97f6e02867485153ec9df98751b36c5c7cb 100644 |
--- a/content/browser/webrtc/webrtc_internals.cc |
+++ b/content/browser/webrtc/webrtc_internals.cc |
@@ -19,6 +19,7 @@ |
#include "content/public/browser/web_contents.h" |
#include "device/power_save_blocker/power_save_blocker.h" |
#include "ipc/ipc_platform_file.h" |
+#include "media/audio/audio_manager.h" |
#include "media/media_features.h" |
#if defined(OS_WIN) |
@@ -323,13 +324,22 @@ void WebRTCInternals::DisableAudioDebugRecordings() { |
// Tear down the dialog since the user has unchecked the audio debug |
// recordings box. |
- select_file_dialog_ = NULL; |
+ select_file_dialog_ = nullptr; |
for (RenderProcessHost::iterator i( |
content::RenderProcessHost::AllHostsIterator()); |
!i.IsAtEnd(); i.Advance()) { |
i.GetCurrentValue()->DisableAudioDebugRecordings(); |
} |
+ |
+ // It's safe to get the AudioManager pointer here. That pointer is invalidated |
+ // on the UI thread, which we're on. |
+ // AudioManager is deleted on the audio thread, and the AudioManager outlives |
+ // this object, so it's safe to post unretained to the audio thread. |
+ media::AudioManager* audio_manager = media::AudioManager::Get(); |
+ audio_manager->GetTaskRunner()->PostTask( |
+ FROM_HERE, base::Bind(&media::AudioManager::DisableOutputDebugRecording, |
+ base::Unretained(audio_manager))); |
#endif |
} |
@@ -493,12 +503,23 @@ void WebRTCInternals::EnableAudioDebugRecordingsOnAllRenderProcessHosts() { |
DCHECK_CURRENTLY_ON(BrowserThread::UI); |
audio_debug_recordings_ = true; |
+ |
for (RenderProcessHost::iterator i( |
content::RenderProcessHost::AllHostsIterator()); |
!i.IsAtEnd(); i.Advance()) { |
i.GetCurrentValue()->EnableAudioDebugRecordings( |
audio_debug_recordings_file_path_); |
} |
+ |
+ // It's safe to get the AudioManager pointer here. That pointer is invalidated |
+ // on the UI thread, which we're on. |
+ // AudioManager is deleted on the audio thread, and the AudioManager outlives |
+ // this object, so it's safe to post unretained to the audio thread. |
+ media::AudioManager* audio_manager = media::AudioManager::Get(); |
+ audio_manager->GetTaskRunner()->PostTask( |
+ FROM_HERE, base::Bind(&media::AudioManager::EnableOutputDebugRecording, |
+ base::Unretained(audio_manager), |
+ audio_debug_recordings_file_path_)); |
} |
void WebRTCInternals::EnableEventLogRecordingsOnAllRenderProcessHosts() { |