| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/basictypes.h" | 13 #include "base/basictypes.h" |
| 14 #include "base/command_line.h" | 14 #include "base/command_line.h" |
| 15 #include "base/file_path.h" | 15 #include "base/file_path.h" |
| 16 #include "base/memory/scoped_ptr.h" | 16 #include "base/memory/scoped_ptr.h" |
| 17 #include "base/path_service.h" | 17 #include "base/path_service.h" |
| 18 #include "base/process_util.h" | 18 #include "base/process_util.h" |
| 19 #include "base/string_number_conversions.h" | 19 #include "base/string_number_conversions.h" |
| 20 #include "base/string_util.h" | 20 #include "base/string_util.h" |
| 21 #include "base/win/windows_version.h" | 21 #include "base/win/windows_version.h" |
| 22 #include "media/audio/fake_audio_input_stream.h" | 22 #include "media/audio/fake_audio_input_stream.h" |
| 23 #include "media/audio/fake_audio_output_stream.h" | 23 #include "media/audio/fake_audio_output_stream.h" |
| 24 #include "media/audio/win/audio_low_latency_input_win.h" |
| 24 #include "media/audio/win/audio_manager_win.h" | 25 #include "media/audio/win/audio_manager_win.h" |
| 25 #include "media/audio/win/wavein_input_win.h" | 26 #include "media/audio/win/wavein_input_win.h" |
| 26 #include "media/audio/win/waveout_output_win.h" | 27 #include "media/audio/win/waveout_output_win.h" |
| 27 #include "media/base/limits.h" | 28 #include "media/base/limits.h" |
| 28 | 29 |
| 29 // Libraries required for the SetupAPI and Wbem APIs used here. | 30 // Libraries required for the SetupAPI and Wbem APIs used here. |
| 30 #pragma comment(lib, "setupapi.lib") | 31 #pragma comment(lib, "setupapi.lib") |
| 31 | 32 |
| 32 // The following are defined in various DDK headers, and we (re)define them | 33 // The following are defined in various DDK headers, and we (re)define them |
| 33 // here to avoid adding the DDK as a chrome dependency. | 34 // here to avoid adding the DDK as a chrome dependency. |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 AudioInputStream* AudioManagerWin::MakeAudioInputStream( | 142 AudioInputStream* AudioManagerWin::MakeAudioInputStream( |
| 142 const AudioParameters& params) { | 143 const AudioParameters& params) { |
| 143 if (!params.IsValid() || (params.channels > kWinMaxInputChannels)) | 144 if (!params.IsValid() || (params.channels > kWinMaxInputChannels)) |
| 144 return NULL; | 145 return NULL; |
| 145 | 146 |
| 146 if (params.format == AudioParameters::AUDIO_MOCK) { | 147 if (params.format == AudioParameters::AUDIO_MOCK) { |
| 147 return FakeAudioInputStream::MakeFakeStream(params); | 148 return FakeAudioInputStream::MakeFakeStream(params); |
| 148 } else if (params.format == AudioParameters::AUDIO_PCM_LINEAR) { | 149 } else if (params.format == AudioParameters::AUDIO_PCM_LINEAR) { |
| 149 return new PCMWaveInAudioInputStream(this, params, kNumInputBuffers, | 150 return new PCMWaveInAudioInputStream(this, params, kNumInputBuffers, |
| 150 WAVE_MAPPER); | 151 WAVE_MAPPER); |
| 152 } else if (params.format == AudioParameters::AUDIO_PCM_LOW_LATENCY) { |
| 153 if (base::win::GetVersion() <= base::win::VERSION_XP) { |
| 154 // Fall back to Windows Wave implementation on Windows XP or lower. |
| 155 DLOG(INFO) << "Using WaveIn since WASAPI requires at least Vista."; |
| 156 return new PCMWaveInAudioInputStream(this, params, kNumInputBuffers, |
| 157 WAVE_MAPPER); |
| 158 } else { |
| 159 // TODO(henrika): improve possibility to specify audio endpoint. |
| 160 // Use the default device (same as for Wave) for now to be compatible. |
| 161 return new WASAPIAudioInputStream(this, params, eConsole); |
| 162 } |
| 151 } | 163 } |
| 152 return NULL; | 164 return NULL; |
| 153 } | 165 } |
| 154 | 166 |
| 155 void AudioManagerWin::ReleaseOutputStream(PCMWaveOutAudioOutputStream* stream) { | 167 void AudioManagerWin::ReleaseOutputStream(PCMWaveOutAudioOutputStream* stream) { |
| 156 DCHECK(stream); | 168 DCHECK(stream); |
| 157 num_output_streams_--; | 169 num_output_streams_--; |
| 158 delete stream; | 170 delete stream; |
| 159 } | 171 } |
| 160 | 172 |
| 161 void AudioManagerWin::ReleaseInputStream(PCMWaveInAudioInputStream* stream) { | 173 void AudioManagerWin::ReleaseInputStream(AudioInputStream* stream) { |
| 162 delete stream; | 174 delete stream; |
| 163 } | 175 } |
| 164 | 176 |
| 165 void AudioManagerWin::MuteAll() { | 177 void AudioManagerWin::MuteAll() { |
| 166 } | 178 } |
| 167 | 179 |
| 168 void AudioManagerWin::UnMuteAll() { | 180 void AudioManagerWin::UnMuteAll() { |
| 169 } | 181 } |
| 170 | 182 |
| 171 string16 AudioManagerWin::GetAudioInputDeviceModel() { | 183 string16 AudioManagerWin::GetAudioInputDeviceModel() { |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 264 name.device_name = AudioManagerBase::kDefaultDeviceName; | 276 name.device_name = AudioManagerBase::kDefaultDeviceName; |
| 265 name.unique_id = "0"; | 277 name.unique_id = "0"; |
| 266 device_names->push_back(name); | 278 device_names->push_back(name); |
| 267 } | 279 } |
| 268 } | 280 } |
| 269 | 281 |
| 270 // static | 282 // static |
| 271 AudioManager* AudioManager::CreateAudioManager() { | 283 AudioManager* AudioManager::CreateAudioManager() { |
| 272 return new AudioManagerWin(); | 284 return new AudioManagerWin(); |
| 273 } | 285 } |
| OLD | NEW |