| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "media/audio/win/audio_device_listener_win.h" | 5 #include "media/audio/win/audio_device_listener_win.h" |
| 6 | 6 |
| 7 #include <Audioclient.h> | 7 #include <Audioclient.h> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 role == eConsole ? | 151 role == eConsole ? |
| 152 &default_capture_device_id_ : | 152 &default_capture_device_id_ : |
| 153 &default_communications_capture_device_id_ | 153 &default_communications_capture_device_id_ |
| 154 ); | 154 ); |
| 155 | 155 |
| 156 // If no device is now available, |new_default_device_id| will be NULL. | 156 // If no device is now available, |new_default_device_id| will be NULL. |
| 157 std::string new_device_id; | 157 std::string new_device_id; |
| 158 if (new_default_device_id) | 158 if (new_default_device_id) |
| 159 new_device_id = base::WideToUTF8(new_default_device_id); | 159 new_device_id = base::WideToUTF8(new_default_device_id); |
| 160 | 160 |
| 161 VLOG(1) << "OnDefaultDeviceChanged() " | 161 DVLOG(1) << "OnDefaultDeviceChanged() " |
| 162 << "new_default_device: " | 162 << "new_default_device: " |
| 163 << (new_default_device_id ? | 163 << (new_default_device_id ? |
| 164 CoreAudioUtil::GetFriendlyName(new_device_id) : "No device") | 164 CoreAudioUtil::GetFriendlyName(new_device_id) : "No device") |
| 165 << ", flow: " << FlowToString(flow) | 165 << ", flow: " << FlowToString(flow) |
| 166 << ", role: " << RoleToString(role); | 166 << ", role: " << RoleToString(role); |
| 167 | 167 |
| 168 // Only fire a state change event if the device has actually changed. | 168 // Only fire a state change event if the device has actually changed. |
| 169 // TODO(dalecurtis): This still seems to fire an extra event on my machine for | 169 // TODO(dalecurtis): This still seems to fire an extra event on my machine for |
| 170 // an unplug event (probably others too); e.g., we get two transitions to a | 170 // an unplug event (probably others too); e.g., we get two transitions to a |
| 171 // new default device id. | 171 // new default device id. |
| 172 if (new_device_id.compare(*current_device_id) == 0) | 172 if (new_device_id.compare(*current_device_id) == 0) |
| 173 return S_OK; | 173 return S_OK; |
| 174 | 174 |
| 175 // Store the new id in the member variable (that current_device_id points to). | 175 // Store the new id in the member variable (that current_device_id points to). |
| 176 *current_device_id = new_device_id; | 176 *current_device_id = new_device_id; |
| 177 listener_cb_.Run(); | 177 listener_cb_.Run(); |
| 178 | 178 |
| 179 return S_OK; | 179 return S_OK; |
| 180 } | 180 } |
| 181 | 181 |
| 182 } // namespace media | 182 } // namespace media |
| OLD | NEW |