OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/mac/audio_device_listener_mac.h" | 5 #include "media/audio/mac/audio_device_listener_mac.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/file_path.h" | 8 #include "base/file_path.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/mac/libdispatch_task_runner.h" | 10 #include "base/mac/libdispatch_task_runner.h" |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
208 kAudioObjectSystemObject, &kDeviceChangePropertyAddress, | 208 kAudioObjectSystemObject, &kDeviceChangePropertyAddress, |
209 &AudioDeviceListenerMac::OnDefaultDeviceChanged, this); | 209 &AudioDeviceListenerMac::OnDefaultDeviceChanged, this); |
210 OSSTATUS_DLOG_IF(ERROR, result != noErr, result) | 210 OSSTATUS_DLOG_IF(ERROR, result != noErr, result) |
211 << "AudioObjectRemovePropertyListener() failed!"; | 211 << "AudioObjectRemovePropertyListener() failed!"; |
212 } | 212 } |
213 | 213 |
214 bool AudioDeviceListenerMac::LoadAudioObjectPropertyListenerBlockFunctions() { | 214 bool AudioDeviceListenerMac::LoadAudioObjectPropertyListenerBlockFunctions() { |
215 // Dynamically load required block functions. | 215 // Dynamically load required block functions. |
216 // TODO(dalecurtis): Remove once the deployment target is > 10.6. | 216 // TODO(dalecurtis): Remove once the deployment target is > 10.6. |
217 std::string error; | 217 std::string error; |
218 base::NativeLibrary core_audio = base::LoadNativeLibrary(FilePath( | 218 base::NativeLibrary core_audio = base::LoadNativeLibrary(base::FilePath( |
219 "/System/Library/Frameworks/CoreAudio.framework/Versions/Current/" | 219 "/System/Library/Frameworks/CoreAudio.framework/Versions/Current/" |
220 "CoreAudio"), &error); | 220 "CoreAudio"), &error); |
221 if (!error.empty()) { | 221 if (!error.empty()) { |
222 LOG(ERROR) << "Could not open CoreAudio library: " << error; | 222 LOG(ERROR) << "Could not open CoreAudio library: " << error; |
223 return false; | 223 return false; |
224 } | 224 } |
225 | 225 |
226 core_audio_lib_.Reset(core_audio); | 226 core_audio_lib_.Reset(core_audio); |
227 add_listener_block_func_ = | 227 add_listener_block_func_ = |
228 reinterpret_cast<AudioObjectPropertyListenerBlockT>( | 228 reinterpret_cast<AudioObjectPropertyListenerBlockT>( |
229 core_audio_lib_.GetFunctionPointer( | 229 core_audio_lib_.GetFunctionPointer( |
230 "AudioObjectAddPropertyListenerBlock")); | 230 "AudioObjectAddPropertyListenerBlock")); |
231 remove_listener_block_func_ = | 231 remove_listener_block_func_ = |
232 reinterpret_cast<AudioObjectPropertyListenerBlockT>( | 232 reinterpret_cast<AudioObjectPropertyListenerBlockT>( |
233 core_audio_lib_.GetFunctionPointer( | 233 core_audio_lib_.GetFunctionPointer( |
234 "AudioObjectRemovePropertyListenerBlock")); | 234 "AudioObjectRemovePropertyListenerBlock")); |
235 | 235 |
236 // If either function failed to load, skip listener registration. | 236 // If either function failed to load, skip listener registration. |
237 if (!add_listener_block_func_ || !remove_listener_block_func_) { | 237 if (!add_listener_block_func_ || !remove_listener_block_func_) { |
238 DLOG(ERROR) << "Failed to load audio property listener block functions!"; | 238 DLOG(ERROR) << "Failed to load audio property listener block functions!"; |
239 return false; | 239 return false; |
240 } | 240 } |
241 | 241 |
242 return true; | 242 return true; |
243 } | 243 } |
244 | 244 |
245 } // namespace media | 245 } // namespace media |
OLD | NEW |