Commit 7e7baf5c authored by Guido Urdaneta's avatar Guido Urdaneta Committed by Commit Bot

Ensure the callback for AudioDeviceListener runs on the thread where it is created.

Notifications from the OS can come on any thread, which may lead to crashes.


Bug: 911311
Change-Id: Ibfd71bf572427e17e17d4fcda92690e8960fd571
Reviewed-on: https://chromium-review.googlesource.com/c/1371871
Commit-Queue: Olga Sharonova <olka@chromium.org>
Reviewed-by: default avatarOlga Sharonova <olka@chromium.org>
Cr-Commit-Position: refs/heads/master@{#615653}
parent 3ceb81ba
......@@ -14,6 +14,7 @@
#include "base/trace_event/trace_event.h"
#include "components/crash/core/common/crash_key.h"
#include "media/audio/audio_manager.h"
#include "media/base/bind_to_current_loop.h"
#include "services/audio/debug_recording.h"
#include "services/audio/device_notifier.h"
#include "services/audio/log_factory_manager.h"
......@@ -203,6 +204,7 @@ void Service::BindLogFactoryManagerRequest(
void Service::InitializeDeviceMonitor() {
CHECK_EQ(magic_bytes_, 0x600DC0DEu);
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
#if defined(OS_MACOSX)
if (audio_device_listener_mac_)
return;
......@@ -210,12 +212,12 @@ void Service::InitializeDeviceMonitor() {
TRACE_EVENT0("audio", "audio::Service::InitializeDeviceMonitor");
audio_device_listener_mac_ = std::make_unique<media::AudioDeviceListenerMac>(
base::BindRepeating([] {
media::BindToCurrentLoop(base::BindRepeating([] {
if (base::SystemMonitor::Get()) {
base::SystemMonitor::Get()->ProcessDevicesChanged(
base::SystemMonitor::DEVTYPE_AUDIO);
}
}),
})),
true /* monitor_default_input */, true /* monitor_addition_removal */,
true /* monitor_sources */);
#endif
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment