| 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/audio_io.h" | 5 #include "media/audio/audio_io.h" |
| 6 | 6 |
| 7 #include <windows.h> | 7 #include <windows.h> |
| 8 #include <objbase.h> // This has to be before initguid.h | 8 #include <objbase.h> // This has to be before initguid.h |
| 9 #include <initguid.h> | 9 #include <initguid.h> |
| 10 #include <mmsystem.h> | 10 #include <mmsystem.h> |
| 11 #include <setupapi.h> | 11 #include <setupapi.h> |
| 12 | 12 |
| 13 #include "base/bind.h" | 13 #include "base/bind.h" |
| 14 #include "base/bind_helpers.h" | 14 #include "base/bind_helpers.h" |
| 15 #include "base/command_line.h" | 15 #include "base/command_line.h" |
| 16 #include "base/files/file_path.h" | 16 #include "base/files/file_path.h" |
| 17 #include "base/memory/scoped_ptr.h" | 17 #include "base/memory/scoped_ptr.h" |
| 18 #include "base/message_loop/message_loop.h" | 18 #include "base/message_loop/message_loop.h" |
| 19 #include "base/metrics/histogram.h" | 19 #include "base/metrics/histogram.h" |
| 20 #include "base/path_service.h" | 20 #include "base/path_service.h" |
| 21 #include "base/process/launch.h" | 21 #include "base/process/launch.h" |
| 22 #include "base/strings/string_number_conversions.h" | 22 #include "base/strings/string_number_conversions.h" |
| 23 #include "base/strings/string_util.h" | 23 #include "base/strings/string_util.h" |
| 24 #include "base/win/windows_version.h" | 24 #include "base/win/windows_version.h" |
| 25 #include "chrome/grit/chromium_strings.h" |
| 26 #include "chrome/grit/generated_resources.h" |
| 25 #include "media/audio/audio_parameters.h" | 27 #include "media/audio/audio_parameters.h" |
| 26 #include "media/audio/win/audio_device_listener_win.h" | 28 #include "media/audio/win/audio_device_listener_win.h" |
| 27 #include "media/audio/win/audio_low_latency_input_win.h" | 29 #include "media/audio/win/audio_low_latency_input_win.h" |
| 28 #include "media/audio/win/audio_low_latency_output_win.h" | 30 #include "media/audio/win/audio_low_latency_output_win.h" |
| 29 #include "media/audio/win/audio_manager_win.h" | 31 #include "media/audio/win/audio_manager_win.h" |
| 30 #include "media/audio/win/core_audio_util_win.h" | 32 #include "media/audio/win/core_audio_util_win.h" |
| 31 #include "media/audio/win/device_enumeration_win.h" | 33 #include "media/audio/win/device_enumeration_win.h" |
| 32 #include "media/audio/win/wavein_input_win.h" | 34 #include "media/audio/win/wavein_input_win.h" |
| 33 #include "media/audio/win/waveout_output_win.h" | 35 #include "media/audio/win/waveout_output_win.h" |
| 34 #include "media/base/bind_to_current_loop.h" | 36 #include "media/base/bind_to_current_loop.h" |
| 35 #include "media/base/channel_layout.h" | 37 #include "media/base/channel_layout.h" |
| 36 #include "media/base/limits.h" | 38 #include "media/base/limits.h" |
| 37 #include "media/base/media_switches.h" | 39 #include "media/base/media_switches.h" |
| 40 #include "ui/base/l10n/l10n_util.h" |
| 38 | 41 |
| 39 // Libraries required for the SetupAPI and Wbem APIs used here. | 42 // Libraries required for the SetupAPI and Wbem APIs used here. |
| 40 #pragma comment(lib, "setupapi.lib") | 43 #pragma comment(lib, "setupapi.lib") |
| 41 | 44 |
| 42 // The following are defined in various DDK headers, and we (re)define them here | 45 // The following are defined in various DDK headers, and we (re)define them here |
| 43 // to avoid adding the DDK as a chrome dependency. | 46 // to avoid adding the DDK as a chrome dependency. |
| 44 #define DRV_QUERYDEVICEINTERFACE 0x80c | 47 #define DRV_QUERYDEVICEINTERFACE 0x80c |
| 45 #define DRVM_MAPPER_PREFERRED_GET 0x2015 | 48 #define DRVM_MAPPER_PREFERRED_GET 0x2015 |
| 46 #define DRV_QUERYDEVICEINTERFACESIZE 0x80d | 49 #define DRV_QUERYDEVICEINTERFACESIZE 0x80d |
| 47 DEFINE_GUID(AM_KSCATEGORY_AUDIO, 0x6994ad04, 0x93ef, 0x11d0, | 50 DEFINE_GUID(AM_KSCATEGORY_AUDIO, 0x6994ad04, 0x93ef, 0x11d0, |
| (...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 279 // Utilize the MMDevice API (part of Core Audio) for Vista and higher. | 282 // Utilize the MMDevice API (part of Core Audio) for Vista and higher. |
| 280 if (input) | 283 if (input) |
| 281 GetInputDeviceNamesWin(device_names); | 284 GetInputDeviceNamesWin(device_names); |
| 282 else | 285 else |
| 283 GetOutputDeviceNamesWin(device_names); | 286 GetOutputDeviceNamesWin(device_names); |
| 284 } | 287 } |
| 285 | 288 |
| 286 if (!device_names->empty()) { | 289 if (!device_names->empty()) { |
| 287 AudioDeviceName name; | 290 AudioDeviceName name; |
| 288 if (enumeration_type() == kMMDeviceEnumeration) { | 291 if (enumeration_type() == kMMDeviceEnumeration) { |
| 289 name.device_name = AudioManagerBase::kCommunicationsDeviceName; | 292 name.device_name = GetCommunicationsDeviceName(); |
| 290 name.unique_id = AudioManagerBase::kCommunicationsDeviceId; | 293 name.unique_id = AudioManagerBase::kCommunicationsDeviceId; |
| 291 device_names->push_front(name); | 294 device_names->push_front(name); |
| 292 } | 295 } |
| 293 // Always add default device parameters as first element. | 296 // Always add default device parameters as first element. |
| 294 name.device_name = AudioManagerBase::kDefaultDeviceName; | 297 name.device_name = GetDefaultDeviceName(); |
| 295 name.unique_id = AudioManagerBase::kDefaultDeviceId; | 298 name.unique_id = AudioManagerBase::kDefaultDeviceId; |
| 296 device_names->push_front(name); | 299 device_names->push_front(name); |
| 297 } | 300 } |
| 298 } | 301 } |
| 299 | 302 |
| 300 void AudioManagerWin::GetAudioInputDeviceNames(AudioDeviceNames* device_names) { | 303 void AudioManagerWin::GetAudioInputDeviceNames(AudioDeviceNames* device_names) { |
| 301 GetAudioDeviceNamesImpl(true, device_names); | 304 GetAudioDeviceNamesImpl(true, device_names); |
| 302 } | 305 } |
| 303 | 306 |
| 304 void AudioManagerWin::GetAudioOutputDeviceNames( | 307 void AudioManagerWin::GetAudioOutputDeviceNames( |
| (...skipping 27 matching lines...) Expand all Loading... |
| 332 std::string AudioManagerWin::GetAssociatedOutputDeviceID( | 335 std::string AudioManagerWin::GetAssociatedOutputDeviceID( |
| 333 const std::string& input_device_id) { | 336 const std::string& input_device_id) { |
| 334 if (!core_audio_supported()) { | 337 if (!core_audio_supported()) { |
| 335 NOTIMPLEMENTED() | 338 NOTIMPLEMENTED() |
| 336 << "GetAssociatedOutputDeviceID is not supported on this OS"; | 339 << "GetAssociatedOutputDeviceID is not supported on this OS"; |
| 337 return std::string(); | 340 return std::string(); |
| 338 } | 341 } |
| 339 return CoreAudioUtil::GetMatchingOutputDeviceID(input_device_id); | 342 return CoreAudioUtil::GetMatchingOutputDeviceID(input_device_id); |
| 340 } | 343 } |
| 341 | 344 |
| 345 std::string AudioManagerWin::GetCommunicationsDeviceName() const { |
| 346 return l10n_util::GetStringUTF8(IDS_COMMUNICATIONS_AUDIO_DEVICE_NAME); |
| 347 } |
| 348 |
| 342 // Factory for the implementations of AudioOutputStream for AUDIO_PCM_LINEAR | 349 // Factory for the implementations of AudioOutputStream for AUDIO_PCM_LINEAR |
| 343 // mode. | 350 // mode. |
| 344 // - PCMWaveOutAudioOutputStream: Based on the waveOut API. | 351 // - PCMWaveOutAudioOutputStream: Based on the waveOut API. |
| 345 AudioOutputStream* AudioManagerWin::MakeLinearOutputStream( | 352 AudioOutputStream* AudioManagerWin::MakeLinearOutputStream( |
| 346 const AudioParameters& params) { | 353 const AudioParameters& params) { |
| 347 DCHECK_EQ(AudioParameters::AUDIO_PCM_LINEAR, params.format()); | 354 DCHECK_EQ(AudioParameters::AUDIO_PCM_LINEAR, params.format()); |
| 348 if (params.channels() > kWinMaxChannels) | 355 if (params.channels() > kWinMaxChannels) |
| 349 return NULL; | 356 return NULL; |
| 350 | 357 |
| 351 return new PCMWaveOutAudioOutputStream(this, | 358 return new PCMWaveOutAudioOutputStream(this, |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 537 return new PCMWaveInAudioInputStream(this, params, kNumInputBuffers, | 544 return new PCMWaveInAudioInputStream(this, params, kNumInputBuffers, |
| 538 xp_device_id); | 545 xp_device_id); |
| 539 } | 546 } |
| 540 | 547 |
| 541 /// static | 548 /// static |
| 542 AudioManager* CreateAudioManager(AudioLogFactory* audio_log_factory) { | 549 AudioManager* CreateAudioManager(AudioLogFactory* audio_log_factory) { |
| 543 return new AudioManagerWin(audio_log_factory); | 550 return new AudioManagerWin(audio_log_factory); |
| 544 } | 551 } |
| 545 | 552 |
| 546 } // namespace media | 553 } // namespace media |
| OLD | NEW |