Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(99)

Side by Side Diff: media/audio/win/audio_manager_win.cc

Issue 1275783003: Add a virtual beamforming audio device on ChromeOS. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: More constructors. Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
305 const std::string& device_id) { 305 const std::string& device_id) {
306 HRESULT hr = E_FAIL; 306 HRESULT hr = E_FAIL;
307 AudioParameters parameters; 307 AudioParameters parameters;
308 if (core_audio_supported()) { 308 if (core_audio_supported()) {
309 hr = CoreAudioUtil::GetPreferredAudioParameters(device_id, false, 309 hr = CoreAudioUtil::GetPreferredAudioParameters(device_id, false,
310 &parameters); 310 &parameters);
311 } 311 }
312 312
313 if (FAILED(hr) || !parameters.IsValid()) { 313 if (FAILED(hr) || !parameters.IsValid()) {
314 // Windows Wave implementation is being used. 314 // Windows Wave implementation is being used.
315 parameters = AudioParameters( 315 parameters =
316 AudioParameters::AUDIO_PCM_LINEAR, CHANNEL_LAYOUT_STEREO, 48000, 16, 316 AudioParameters(AudioParameters::AUDIO_PCM_LINEAR,
317 kFallbackBufferSize, AudioParameters::NO_EFFECTS); 317 CHANNEL_LAYOUT_STEREO, 48000, 16, kFallbackBufferSize);
318 } 318 }
319 319
320 int user_buffer_size = GetUserBufferSize(); 320 int user_buffer_size = GetUserBufferSize();
321 if (user_buffer_size) { 321 if (user_buffer_size) {
322 parameters.Reset(parameters.format(), parameters.channel_layout(), 322 parameters.Reset(parameters.format(), parameters.channel_layout(),
323 parameters.channels(), parameters.sample_rate(), 323 parameters.channels(), parameters.sample_rate(),
324 parameters.bits_per_sample(), user_buffer_size); 324 parameters.bits_per_sample(), user_buffer_size);
325 } 325 }
326 326
327 return parameters; 327 return parameters;
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
506 sample_rate = input_params.sample_rate(); 506 sample_rate = input_params.sample_rate();
507 } 507 }
508 } 508 }
509 509
510 int user_buffer_size = GetUserBufferSize(); 510 int user_buffer_size = GetUserBufferSize();
511 if (user_buffer_size) 511 if (user_buffer_size)
512 buffer_size = user_buffer_size; 512 buffer_size = user_buffer_size;
513 513
514 return AudioParameters( 514 return AudioParameters(
515 AudioParameters::AUDIO_PCM_LOW_LATENCY, channel_layout, 515 AudioParameters::AUDIO_PCM_LOW_LATENCY, channel_layout,
516 sample_rate, bits_per_sample, buffer_size, effects); 516 sample_rate, bits_per_sample, buffer_size, "", effects);
517 } 517 }
518 518
519 AudioInputStream* AudioManagerWin::CreatePCMWaveInAudioInputStream( 519 AudioInputStream* AudioManagerWin::CreatePCMWaveInAudioInputStream(
520 const AudioParameters& params, 520 const AudioParameters& params,
521 const std::string& device_id) { 521 const std::string& device_id) {
522 std::string xp_device_id = device_id; 522 std::string xp_device_id = device_id;
523 if (device_id != AudioManagerBase::kDefaultDeviceId && 523 if (device_id != AudioManagerBase::kDefaultDeviceId &&
524 enumeration_type_ == kMMDeviceEnumeration) { 524 enumeration_type_ == kMMDeviceEnumeration) {
525 xp_device_id = ConvertToWinXPInputDeviceId(device_id); 525 xp_device_id = ConvertToWinXPInputDeviceId(device_id);
526 if (xp_device_id.empty()) { 526 if (xp_device_id.empty()) {
527 DLOG(ERROR) << "Cannot find a waveIn device which matches the device ID " 527 DLOG(ERROR) << "Cannot find a waveIn device which matches the device ID "
528 << device_id; 528 << device_id;
529 return NULL; 529 return NULL;
530 } 530 }
531 } 531 }
532 532
533 return new PCMWaveInAudioInputStream(this, params, kNumInputBuffers, 533 return new PCMWaveInAudioInputStream(this, params, kNumInputBuffers,
534 xp_device_id); 534 xp_device_id);
535 } 535 }
536 536
537 /// static 537 /// static
538 AudioManager* CreateAudioManager(AudioLogFactory* audio_log_factory) { 538 AudioManager* CreateAudioManager(AudioLogFactory* audio_log_factory) {
539 return new AudioManagerWin(audio_log_factory); 539 return new AudioManagerWin(audio_log_factory);
540 } 540 }
541 541
542 } // namespace media 542 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698