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/win/audio_manager_win.h" | 5 #include "media/audio/win/audio_manager_win.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 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
328 << "GetAssociatedOutputDeviceID is not supported on this OS"; | 328 << "GetAssociatedOutputDeviceID is not supported on this OS"; |
329 return std::string(); | 329 return std::string(); |
330 } | 330 } |
331 return CoreAudioUtil::GetMatchingOutputDeviceID(input_device_id); | 331 return CoreAudioUtil::GetMatchingOutputDeviceID(input_device_id); |
332 } | 332 } |
333 | 333 |
334 // Factory for the implementations of AudioOutputStream for AUDIO_PCM_LINEAR | 334 // Factory for the implementations of AudioOutputStream for AUDIO_PCM_LINEAR |
335 // mode. | 335 // mode. |
336 // - PCMWaveOutAudioOutputStream: Based on the waveOut API. | 336 // - PCMWaveOutAudioOutputStream: Based on the waveOut API. |
337 AudioOutputStream* AudioManagerWin::MakeLinearOutputStream( | 337 AudioOutputStream* AudioManagerWin::MakeLinearOutputStream( |
338 const AudioParameters& params) { | 338 const AudioParameters& params, |
| 339 const LogCallback& log_callback) { |
339 DCHECK_EQ(AudioParameters::AUDIO_PCM_LINEAR, params.format()); | 340 DCHECK_EQ(AudioParameters::AUDIO_PCM_LINEAR, params.format()); |
340 if (params.channels() > kWinMaxChannels) | 341 if (params.channels() > kWinMaxChannels) |
341 return NULL; | 342 return NULL; |
342 | 343 |
343 return new PCMWaveOutAudioOutputStream(this, | 344 return new PCMWaveOutAudioOutputStream(this, |
344 params, | 345 params, |
345 NumberOfWaveOutBuffers(), | 346 NumberOfWaveOutBuffers(), |
346 WAVE_MAPPER); | 347 WAVE_MAPPER); |
347 } | 348 } |
348 | 349 |
349 // Factory for the implementations of AudioOutputStream for | 350 // Factory for the implementations of AudioOutputStream for |
350 // AUDIO_PCM_LOW_LATENCY mode. Two implementations should suffice most | 351 // AUDIO_PCM_LOW_LATENCY mode. Two implementations should suffice most |
351 // windows user's needs. | 352 // windows user's needs. |
352 // - PCMWaveOutAudioOutputStream: Based on the waveOut API. | 353 // - PCMWaveOutAudioOutputStream: Based on the waveOut API. |
353 // - WASAPIAudioOutputStream: Based on Core Audio (WASAPI) API. | 354 // - WASAPIAudioOutputStream: Based on Core Audio (WASAPI) API. |
354 AudioOutputStream* AudioManagerWin::MakeLowLatencyOutputStream( | 355 AudioOutputStream* AudioManagerWin::MakeLowLatencyOutputStream( |
355 const AudioParameters& params, | 356 const AudioParameters& params, |
356 const std::string& device_id) { | 357 const std::string& device_id, |
| 358 const LogCallback& log_callback) { |
357 DCHECK_EQ(AudioParameters::AUDIO_PCM_LOW_LATENCY, params.format()); | 359 DCHECK_EQ(AudioParameters::AUDIO_PCM_LOW_LATENCY, params.format()); |
358 if (params.channels() > kWinMaxChannels) | 360 if (params.channels() > kWinMaxChannels) |
359 return NULL; | 361 return NULL; |
360 | 362 |
361 if (!core_audio_supported()) { | 363 if (!core_audio_supported()) { |
362 // Fall back to Windows Wave implementation on Windows XP or lower. | 364 // Fall back to Windows Wave implementation on Windows XP or lower. |
363 DLOG_IF(ERROR, !device_id.empty() && | 365 DLOG_IF(ERROR, !device_id.empty() && |
364 device_id != AudioDeviceDescription::kDefaultDeviceId) | 366 device_id != AudioDeviceDescription::kDefaultDeviceId) |
365 << "Opening by device id not supported by PCMWaveOutAudioOutputStream"; | 367 << "Opening by device id not supported by PCMWaveOutAudioOutputStream"; |
366 DVLOG(1) << "Using WaveOut since WASAPI requires at least Vista."; | 368 DVLOG(1) << "Using WaveOut since WASAPI requires at least Vista."; |
(...skipping 10 matching lines...) Expand all Loading... |
377 this, | 379 this, |
378 communications || device_id == AudioDeviceDescription::kDefaultDeviceId | 380 communications || device_id == AudioDeviceDescription::kDefaultDeviceId |
379 ? std::string() | 381 ? std::string() |
380 : device_id, | 382 : device_id, |
381 params, communications ? eCommunications : eConsole); | 383 params, communications ? eCommunications : eConsole); |
382 } | 384 } |
383 | 385 |
384 // Factory for the implementations of AudioInputStream for AUDIO_PCM_LINEAR | 386 // Factory for the implementations of AudioInputStream for AUDIO_PCM_LINEAR |
385 // mode. | 387 // mode. |
386 AudioInputStream* AudioManagerWin::MakeLinearInputStream( | 388 AudioInputStream* AudioManagerWin::MakeLinearInputStream( |
387 const AudioParameters& params, const std::string& device_id) { | 389 const AudioParameters& params, |
| 390 const std::string& device_id, |
| 391 const LogCallback& log_callback) { |
388 DCHECK_EQ(AudioParameters::AUDIO_PCM_LINEAR, params.format()); | 392 DCHECK_EQ(AudioParameters::AUDIO_PCM_LINEAR, params.format()); |
389 return CreatePCMWaveInAudioInputStream(params, device_id); | 393 return CreatePCMWaveInAudioInputStream(params, device_id); |
390 } | 394 } |
391 | 395 |
392 // Factory for the implementations of AudioInputStream for | 396 // Factory for the implementations of AudioInputStream for |
393 // AUDIO_PCM_LOW_LATENCY mode. | 397 // AUDIO_PCM_LOW_LATENCY mode. |
394 AudioInputStream* AudioManagerWin::MakeLowLatencyInputStream( | 398 AudioInputStream* AudioManagerWin::MakeLowLatencyInputStream( |
395 const AudioParameters& params, const std::string& device_id) { | 399 const AudioParameters& params, |
| 400 const std::string& device_id, |
| 401 const LogCallback& log_callback) { |
396 DCHECK_EQ(AudioParameters::AUDIO_PCM_LOW_LATENCY, params.format()); | 402 DCHECK_EQ(AudioParameters::AUDIO_PCM_LOW_LATENCY, params.format()); |
397 DVLOG(1) << "MakeLowLatencyInputStream: " << device_id; | 403 DVLOG(1) << "MakeLowLatencyInputStream: " << device_id; |
398 AudioInputStream* stream = NULL; | 404 AudioInputStream* stream = NULL; |
399 UMA_HISTOGRAM_BOOLEAN("Media.WindowsCoreAudioInput", core_audio_supported()); | 405 UMA_HISTOGRAM_BOOLEAN("Media.WindowsCoreAudioInput", core_audio_supported()); |
400 if (!core_audio_supported()) { | 406 if (!core_audio_supported()) { |
401 // Fall back to Windows Wave implementation on Windows XP or lower. | 407 // Fall back to Windows Wave implementation on Windows XP or lower. |
402 DVLOG(1) << "Using WaveIn since WASAPI requires at least Vista."; | 408 DVLOG(1) << "Using WaveIn since WASAPI requires at least Vista."; |
403 stream = CreatePCMWaveInAudioInputStream(params, device_id); | 409 stream = CreatePCMWaveInAudioInputStream(params, device_id); |
404 } else { | 410 } else { |
405 stream = new WASAPIAudioInputStream(this, params, device_id); | 411 stream = new WASAPIAudioInputStream(this, params, device_id); |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
536 ScopedAudioManagerPtr CreateAudioManager( | 542 ScopedAudioManagerPtr CreateAudioManager( |
537 scoped_refptr<base::SingleThreadTaskRunner> task_runner, | 543 scoped_refptr<base::SingleThreadTaskRunner> task_runner, |
538 scoped_refptr<base::SingleThreadTaskRunner> worker_task_runner, | 544 scoped_refptr<base::SingleThreadTaskRunner> worker_task_runner, |
539 AudioLogFactory* audio_log_factory) { | 545 AudioLogFactory* audio_log_factory) { |
540 return ScopedAudioManagerPtr( | 546 return ScopedAudioManagerPtr( |
541 new AudioManagerWin(std::move(task_runner), std::move(worker_task_runner), | 547 new AudioManagerWin(std::move(task_runner), std::move(worker_task_runner), |
542 audio_log_factory)); | 548 audio_log_factory)); |
543 } | 549 } |
544 | 550 |
545 } // namespace media | 551 } // namespace media |
OLD | NEW |