Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(81)

Unified Diff: media/audio/win/audio_device_listener_win.cc

Issue 1248543002: Remove device change deduplication based on device id. (Closed) Base URL: http://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « media/audio/win/audio_device_listener_win.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/audio/win/audio_device_listener_win.cc
diff --git a/media/audio/win/audio_device_listener_win.cc b/media/audio/win/audio_device_listener_win.cc
index 624c0ccd7ab0762c147452dad0542600e108a335..ac293bb755d311cc1e255ba2db470e2fcd52f5e8 100644
--- a/media/audio/win/audio_device_listener_win.cc
+++ b/media/audio/win/audio_device_listener_win.cc
@@ -68,13 +68,6 @@ AudioDeviceListenerWin::AudioDeviceListenerWin(const base::Closure& listener_cb)
}
device_enumerator_ = device_enumerator;
-
- default_render_device_id_ = GetDeviceId(eRender, eConsole);
henrika_webrtc 2015/07/21 09:42:24 Nice to get rid of all these ;-)
- default_capture_device_id_ = GetDeviceId(eCapture, eConsole);
- default_communications_render_device_id_ =
- GetDeviceId(eRender, eCommunications);
- default_communications_capture_device_id_ =
- GetDeviceId(eCapture, eCommunications);
}
AudioDeviceListenerWin::~AudioDeviceListenerWin() {
@@ -140,41 +133,35 @@ STDMETHODIMP AudioDeviceListenerWin::OnDefaultDeviceChanged(
return S_OK;
}
- // Grab a pointer to the appropriate ID member.
- // Note that there are three "?:"'s here to select the right ID.
- std::string* current_device_id =
- flow == eRender ? (
- role == eConsole ?
- &default_render_device_id_ :
- &default_communications_render_device_id_
- ) : (
- role == eConsole ?
- &default_capture_device_id_ :
- &default_communications_capture_device_id_
- );
-
// If no device is now available, |new_default_device_id| will be NULL.
std::string new_device_id;
if (new_default_device_id)
new_device_id = base::WideToUTF8(new_default_device_id);
+ // Only output device changes should be forwarded. Do not attempt to filter
+ // changes based on device id since some devices may not change their device
+ // id and instead trigger some internal flow change: http://crbug.com/506712
+ //
+ // We rate limit device changes to avoid a single device change causing back
+ // to back changes for eCommunications and eConsole; this is worth doing as
+ // it provides a substantially faster resumption of playback.
+ bool did_run_listener_cb = false;
+ const base::TimeTicks now = base::TimeTicks::Now();
+ if (flow == eRender &&
+ now - last_device_change_time_ > base::TimeDelta::FromMilliseconds(250)) {
henrika_webrtc 2015/07/21 09:42:23 How did you come up with 250?
DaleCurtis 2015/07/21 19:03:36 Dice roll! Well actually... I physically couldn't
henrika (OOO until Aug 14) 2015/07/22 07:58:20 Acknowledged.
+ last_device_change_time_ = now;
+ listener_cb_.Run();
+ did_run_listener_cb = true;
henrika_webrtc 2015/07/21 09:42:23 Is did_run_listener_cb ever used?
DaleCurtis 2015/07/21 19:03:36 In the DVLOG() below.
henrika (OOO until Aug 14) 2015/07/22 07:58:20 Acknowledged.
+ }
+
DVLOG(1) << "OnDefaultDeviceChanged() "
<< "new_default_device: "
- << (new_default_device_id ?
- CoreAudioUtil::GetFriendlyName(new_device_id) : "No device")
+ << (new_default_device_id
+ ? CoreAudioUtil::GetFriendlyName(new_device_id)
+ : "no device")
<< ", flow: " << FlowToString(flow)
- << ", role: " << RoleToString(role);
-
- // Only fire a state change event if the device has actually changed.
- // TODO(dalecurtis): This still seems to fire an extra event on my machine for
- // an unplug event (probably others too); e.g., we get two transitions to a
- // new default device id.
- if (new_device_id.compare(*current_device_id) == 0)
- return S_OK;
-
- // Store the new id in the member variable (that current_device_id points to).
- *current_device_id = new_device_id;
- listener_cb_.Run();
+ << ", role: " << RoleToString(role)
+ << ", notified manager: " << (did_run_listener_cb ? "Yes" : "No");
return S_OK;
}
« no previous file with comments | « media/audio/win/audio_device_listener_win.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698