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

Unified Diff: chromeos/audio/cras_audio_handler.cc

Issue 23620055: Fix the bluetooth audio device id changing on the fly issue and the active device inconsistent issu… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 3 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 | « chromeos/audio/cras_audio_handler.h ('k') | chromeos/audio/cras_audio_handler_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chromeos/audio/cras_audio_handler.cc
diff --git a/chromeos/audio/cras_audio_handler.cc b/chromeos/audio/cras_audio_handler.cc
index 5460466c4b5ef0c94a972b04e4e7f5975888ffad..60663eb5be52041ad872be1598f34d7180c84e55 100644
--- a/chromeos/audio/cras_audio_handler.cc
+++ b/chromeos/audio/cras_audio_handler.cc
@@ -30,6 +30,11 @@ const int kMuteThresholdPercent = 1;
static CrasAudioHandler* g_cras_audio_handler = NULL;
+bool IsSameAudioDevice(const AudioDevice& a, const AudioDevice& b) {
+ return a.id == b.id && a.is_input == b.is_input && a.type == b.type
rkc 2013/09/16 22:38:11 Shouldn't just comparing the id's be enough? IIRC,
jennyz 2013/09/16 22:47:03 I am being extra careful here, after observing cra
+ && a.device_name == b.device_name;
+}
+
} // namespace
CrasAudioHandler::AudioObserver::AudioObserver() {
@@ -562,12 +567,31 @@ bool CrasAudioHandler::HasDeviceChange(const AudioNodeList& new_nodes,
for (AudioNodeList::const_iterator it = new_nodes.begin();
it != new_nodes.end(); ++it) {
- if (is_input == it->is_input)
+ if (is_input == it->is_input) {
++num_new_devices;
+ // Look to see if the new device not in the old device list.
+ AudioDevice device(*it);
+ if (FoundNewDevice(device))
+ return true;
+ }
}
return num_old_devices != num_new_devices;
}
+bool CrasAudioHandler::FoundNewDevice(const AudioDevice& device) {
+ const AudioDevice* device_found = GetDeviceFromId(device.id);
+ if (!device_found)
+ return true;
+
+ if (!IsSameAudioDevice(device, *device_found)) {
+ LOG(WARNING) << "Different Audio devices with same id:"
+ << " new device: " << device.ToString()
+ << " old device: " << device_found->ToString();
+ return true;
+ }
+ return false;
+}
+
void CrasAudioHandler::UpdateDevicesAndSwitchActive(
const AudioNodeList& nodes) {
size_t old_audio_devices_size = audio_devices_.size();
« no previous file with comments | « chromeos/audio/cras_audio_handler.h ('k') | chromeos/audio/cras_audio_handler_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698