| 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> |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 } else if (params.format == AudioParameters::AUDIO_PCM_LOW_LATENCY) { | 133 } else if (params.format == AudioParameters::AUDIO_PCM_LOW_LATENCY) { |
| 134 num_output_streams_++; | 134 num_output_streams_++; |
| 135 // TODO(cpu): waveout cannot hit 20ms latency. Use other method. | 135 // TODO(cpu): waveout cannot hit 20ms latency. Use other method. |
| 136 return new PCMWaveOutAudioOutputStream(this, params, 2, WAVE_MAPPER); | 136 return new PCMWaveOutAudioOutputStream(this, params, 2, WAVE_MAPPER); |
| 137 } | 137 } |
| 138 return NULL; | 138 return NULL; |
| 139 } | 139 } |
| 140 | 140 |
| 141 // Factory for the implementations of AudioInputStream. | 141 // Factory for the implementations of AudioInputStream. |
| 142 AudioInputStream* AudioManagerWin::MakeAudioInputStream( | 142 AudioInputStream* AudioManagerWin::MakeAudioInputStream( |
| 143 const AudioParameters& params) { | 143 const AudioParameters& params, const std::string& device_uid) { |
| 144 if (!params.IsValid() || (params.channels > kWinMaxInputChannels)) | 144 if (!params.IsValid() || (params.channels > kWinMaxInputChannels)) |
| 145 return NULL; | 145 return NULL; |
| 146 | 146 |
| 147 if (params.format == AudioParameters::AUDIO_MOCK) { | 147 if (params.format == AudioParameters::AUDIO_MOCK) { |
| 148 return FakeAudioInputStream::MakeFakeStream(params); | 148 return FakeAudioInputStream::MakeFakeStream(params); |
| 149 } else if (params.format == AudioParameters::AUDIO_PCM_LINEAR) { | 149 } else if (params.format == AudioParameters::AUDIO_PCM_LINEAR) { |
| 150 return new PCMWaveInAudioInputStream(this, params, kNumInputBuffers, | 150 return new PCMWaveInAudioInputStream(this, params, kNumInputBuffers, |
| 151 WAVE_MAPPER); | 151 WAVE_MAPPER); |
| 152 } else if (params.format == AudioParameters::AUDIO_PCM_LOW_LATENCY) { | 152 } else if (params.format == AudioParameters::AUDIO_PCM_LOW_LATENCY) { |
| 153 if (base::win::GetVersion() <= base::win::VERSION_XP) { | 153 if (base::win::GetVersion() <= base::win::VERSION_XP) { |
| 154 // Fall back to Windows Wave implementation on Windows XP or lower. | 154 // Fall back to Windows Wave implementation on Windows XP or lower. |
| 155 DLOG(INFO) << "Using WaveIn since WASAPI requires at least Vista."; | 155 DLOG(INFO) << "Using WaveIn since WASAPI requires at least Vista."; |
| 156 return new PCMWaveInAudioInputStream(this, params, kNumInputBuffers, | 156 // TODO(xians): Handle the non-default device. |
| 157 WAVE_MAPPER); | 157 if ((device_uid == AudioManagerBase::kDefaultDeviceId) || |
| 158 device_uid.empty()) |
| 159 return new PCMWaveInAudioInputStream(this, params, kNumInputBuffers, |
| 160 WAVE_MAPPER); |
| 158 } else { | 161 } else { |
| 159 // TODO(henrika): improve possibility to specify audio endpoint. | 162 // TODO(henrika): improve possibility to specify audio endpoint. |
| 160 // Use the default device (same as for Wave) for now to be compatible. | 163 // Use the default device (same as for Wave) for now to be compatible. |
| 161 return new WASAPIAudioInputStream(this, params, eConsole); | 164 // TODO(xians): Handle the non-default device. |
| 165 if ((device_uid == AudioManagerBase::kDefaultDeviceId) || |
| 166 device_uid.empty()) |
| 167 return new WASAPIAudioInputStream(this, params, eConsole); |
| 162 } | 168 } |
| 163 } | 169 } |
| 164 return NULL; | 170 return NULL; |
| 165 } | 171 } |
| 166 | 172 |
| 167 void AudioManagerWin::ReleaseOutputStream(PCMWaveOutAudioOutputStream* stream) { | 173 void AudioManagerWin::ReleaseOutputStream(PCMWaveOutAudioOutputStream* stream) { |
| 168 DCHECK(stream); | 174 DCHECK(stream); |
| 169 num_output_streams_--; | 175 num_output_streams_--; |
| 170 delete stream; | 176 delete stream; |
| 171 } | 177 } |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 267 | 273 |
| 268 void AudioManagerWin::GetAudioInputDeviceNames( | 274 void AudioManagerWin::GetAudioInputDeviceNames( |
| 269 media::AudioDeviceNames* device_names) { | 275 media::AudioDeviceNames* device_names) { |
| 270 // TODO(xians): query a full list of valid devices. | 276 // TODO(xians): query a full list of valid devices. |
| 271 if (HasAudioInputDevices()) { | 277 if (HasAudioInputDevices()) { |
| 272 // Add the default device to the list. | 278 // Add the default device to the list. |
| 273 // We use index 0 to make up the unique_id to identify the | 279 // We use index 0 to make up the unique_id to identify the |
| 274 // default devices. | 280 // default devices. |
| 275 media::AudioDeviceName name; | 281 media::AudioDeviceName name; |
| 276 name.device_name = AudioManagerBase::kDefaultDeviceName; | 282 name.device_name = AudioManagerBase::kDefaultDeviceName; |
| 277 name.unique_id = "0"; | 283 name.unique_id = AudioManagerBase::kDefaultDeviceId; |
| 278 device_names->push_back(name); | 284 device_names->push_back(name); |
| 279 } | 285 } |
| 280 } | 286 } |
| 281 | 287 |
| 282 // static | 288 // static |
| 283 AudioManager* AudioManager::CreateAudioManager() { | 289 AudioManager* AudioManager::CreateAudioManager() { |
| 284 return new AudioManagerWin(); | 290 return new AudioManagerWin(); |
| 285 } | 291 } |
| OLD | NEW |