Commit 4b467095 authored by Bill Carr's avatar Bill Carr Committed by Commit Bot

Audio Output not Synchronized to Bluetooth Device

When a bluetooth device is connected that should be the system default or app default we may get a series of device change events that look something like bluetooth device -> system device (previous default) -> bluetooth device.

In these cases if the final transition to bluetooth device occurs within 250ms of the device change notification for the system device we will ignore that change due to the current code that tries to protect against redundant role change notifications.

Since in this case we do want to process the change and transition to the bluetooth device adding an additional check to ensure that the device id has not changed when ignoring a device change due to role timeout.

Bug: 1095667
Change-Id: Ib6518a27f60aa2a0acfa592eb51fffaf375fc407
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2245797Reviewed-by: default avatarDale Curtis <dalecurtis@chromium.org>
Commit-Queue: William Carr <wicarr@microsoft.com>
Cr-Commit-Position: refs/heads/master@{#779943}
parent d8675a0e
......@@ -19,7 +19,7 @@ using base::win::ScopedCoMem;
namespace media {
static std::string FlowToString(EDataFlow flow) {
return flow == eRender ? "eRender" : "eConsole";
return flow == eRender ? "eRender" : "eCapture";
}
static std::string RoleToString(ERole role) {
......@@ -134,8 +134,10 @@ HRESULT AudioDeviceListenerWin::OnDefaultDeviceChanged(
// it provides a substantially faster resumption of playback.
bool did_run_listener_cb = false;
const base::TimeTicks now = tick_clock_->NowTicks();
if (flow == eRender && now - last_device_change_time_ > kDeviceChangeLimit) {
if (flow == eRender && (now - last_device_change_time_ > kDeviceChangeLimit ||
new_device_id.compare(last_device_id_) != 0)) {
last_device_change_time_ = now;
last_device_id_ = new_device_id;
listener_cb_.Run();
did_run_listener_cb = true;
}
......
......@@ -63,6 +63,7 @@ class MEDIA_EXPORT AudioDeviceListenerWin : public IMMNotificationClient {
// Used to rate limit device change events.
base::TimeTicks last_device_change_time_;
std::string last_device_id_;
// AudioDeviceListenerWin must be constructed and destructed on one thread.
THREAD_CHECKER(thread_checker_);
......
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