| 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> |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 231 name.unique_id = AudioManagerBase::kDefaultDeviceId; | 231 name.unique_id = AudioManagerBase::kDefaultDeviceId; |
| 232 device_names->push_front(name); | 232 device_names->push_front(name); |
| 233 } | 233 } |
| 234 } | 234 } |
| 235 | 235 |
| 236 // Factory for the implementations of AudioOutputStream for AUDIO_PCM_LINEAR | 236 // Factory for the implementations of AudioOutputStream for AUDIO_PCM_LINEAR |
| 237 // mode. | 237 // mode. |
| 238 // - PCMWaveOutAudioOutputStream: Based on the waveOut API. | 238 // - PCMWaveOutAudioOutputStream: Based on the waveOut API. |
| 239 AudioOutputStream* AudioManagerWin::MakeLinearOutputStream( | 239 AudioOutputStream* AudioManagerWin::MakeLinearOutputStream( |
| 240 const AudioParameters& params) { | 240 const AudioParameters& params) { |
| 241 DCHECK_EQ(AudioParameters::AUDIO_PCM_LINEAR, params.format); | 241 DCHECK_EQ(AudioParameters::AUDIO_PCM_LINEAR, params.format()); |
| 242 if (params.channels > kWinMaxChannels) | 242 if (params.channels() > kWinMaxChannels) |
| 243 return NULL; | 243 return NULL; |
| 244 | 244 |
| 245 return new PCMWaveOutAudioOutputStream(this, params, 3, WAVE_MAPPER); | 245 return new PCMWaveOutAudioOutputStream(this, params, 3, WAVE_MAPPER); |
| 246 } | 246 } |
| 247 | 247 |
| 248 // Factory for the implementations of AudioOutputStream for | 248 // Factory for the implementations of AudioOutputStream for |
| 249 // AUDIO_PCM_LOW_LATENCY mode. Two implementations should suffice most | 249 // AUDIO_PCM_LOW_LATENCY mode. Two implementations should suffice most |
| 250 // windows user's needs. | 250 // windows user's needs. |
| 251 // - PCMWaveOutAudioOutputStream: Based on the waveOut API. | 251 // - PCMWaveOutAudioOutputStream: Based on the waveOut API. |
| 252 // - WASAPIAudioOutputStream: Based on Core Audio (WASAPI) API. | 252 // - WASAPIAudioOutputStream: Based on Core Audio (WASAPI) API. |
| 253 AudioOutputStream* AudioManagerWin::MakeLowLatencyOutputStream( | 253 AudioOutputStream* AudioManagerWin::MakeLowLatencyOutputStream( |
| 254 const AudioParameters& params) { | 254 const AudioParameters& params) { |
| 255 DCHECK_EQ(AudioParameters::AUDIO_PCM_LOW_LATENCY, params.format); | 255 DCHECK_EQ(AudioParameters::AUDIO_PCM_LOW_LATENCY, params.format()); |
| 256 if (params.channels > kWinMaxChannels) | 256 if (params.channels() > kWinMaxChannels) |
| 257 return NULL; | 257 return NULL; |
| 258 | 258 |
| 259 AudioOutputStream* stream = NULL; | 259 AudioOutputStream* stream = NULL; |
| 260 if (!media::IsWASAPISupported()) { | 260 if (!media::IsWASAPISupported()) { |
| 261 // Fall back to Windows Wave implementation on Windows XP or lower. | 261 // Fall back to Windows Wave implementation on Windows XP or lower. |
| 262 DVLOG(1) << "Using WaveOut since WASAPI requires at least Vista."; | 262 DVLOG(1) << "Using WaveOut since WASAPI requires at least Vista."; |
| 263 stream = new PCMWaveOutAudioOutputStream(this, params, 2, WAVE_MAPPER); | 263 stream = new PCMWaveOutAudioOutputStream(this, params, 2, WAVE_MAPPER); |
| 264 } else { | 264 } else { |
| 265 // TODO(henrika): improve possibility to specify audio endpoint. | 265 // TODO(henrika): improve possibility to specify audio endpoint. |
| 266 // Use the default device (same as for Wave) for now to be compatible. | 266 // Use the default device (same as for Wave) for now to be compatible. |
| 267 stream = new WASAPIAudioOutputStream(this, params, eConsole); | 267 stream = new WASAPIAudioOutputStream(this, params, eConsole); |
| 268 } | 268 } |
| 269 | 269 |
| 270 return stream; | 270 return stream; |
| 271 } | 271 } |
| 272 | 272 |
| 273 // Factory for the implementations of AudioInputStream for AUDIO_PCM_LINEAR | 273 // Factory for the implementations of AudioInputStream for AUDIO_PCM_LINEAR |
| 274 // mode. | 274 // mode. |
| 275 AudioInputStream* AudioManagerWin::MakeLinearInputStream( | 275 AudioInputStream* AudioManagerWin::MakeLinearInputStream( |
| 276 const AudioParameters& params, const std::string& device_id) { | 276 const AudioParameters& params, const std::string& device_id) { |
| 277 DCHECK_EQ(AudioParameters::AUDIO_PCM_LINEAR, params.format); | 277 DCHECK_EQ(AudioParameters::AUDIO_PCM_LINEAR, params.format()); |
| 278 return CreatePCMWaveInAudioInputStream(params, device_id); | 278 return CreatePCMWaveInAudioInputStream(params, device_id); |
| 279 } | 279 } |
| 280 | 280 |
| 281 // Factory for the implementations of AudioInputStream for | 281 // Factory for the implementations of AudioInputStream for |
| 282 // AUDIO_PCM_LOW_LATENCY mode. | 282 // AUDIO_PCM_LOW_LATENCY mode. |
| 283 AudioInputStream* AudioManagerWin::MakeLowLatencyInputStream( | 283 AudioInputStream* AudioManagerWin::MakeLowLatencyInputStream( |
| 284 const AudioParameters& params, const std::string& device_id) { | 284 const AudioParameters& params, const std::string& device_id) { |
| 285 DCHECK_EQ(AudioParameters::AUDIO_PCM_LOW_LATENCY, params.format); | 285 DCHECK_EQ(AudioParameters::AUDIO_PCM_LOW_LATENCY, params.format()); |
| 286 AudioInputStream* stream = NULL; | 286 AudioInputStream* stream = NULL; |
| 287 if (!media::IsWASAPISupported()) { | 287 if (!media::IsWASAPISupported()) { |
| 288 // Fall back to Windows Wave implementation on Windows XP or lower. | 288 // Fall back to Windows Wave implementation on Windows XP or lower. |
| 289 DVLOG(1) << "Using WaveIn since WASAPI requires at least Vista."; | 289 DVLOG(1) << "Using WaveIn since WASAPI requires at least Vista."; |
| 290 stream = CreatePCMWaveInAudioInputStream(params, device_id); | 290 stream = CreatePCMWaveInAudioInputStream(params, device_id); |
| 291 } else { | 291 } else { |
| 292 stream = new WASAPIAudioInputStream(this, params, device_id); | 292 stream = new WASAPIAudioInputStream(this, params, device_id); |
| 293 } | 293 } |
| 294 | 294 |
| 295 return stream; | 295 return stream; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 310 } | 310 } |
| 311 | 311 |
| 312 return new PCMWaveInAudioInputStream(this, params, kNumInputBuffers, | 312 return new PCMWaveInAudioInputStream(this, params, kNumInputBuffers, |
| 313 xp_device_id); | 313 xp_device_id); |
| 314 } | 314 } |
| 315 | 315 |
| 316 /// static | 316 /// static |
| 317 AudioManager* CreateAudioManager() { | 317 AudioManager* CreateAudioManager() { |
| 318 return new AudioManagerWin(); | 318 return new AudioManagerWin(); |
| 319 } | 319 } |
| OLD | NEW |