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

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: mcasas comments 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 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
310 const std::string& device_id) { 310 const std::string& device_id) {
311 HRESULT hr = E_FAIL; 311 HRESULT hr = E_FAIL;
312 AudioParameters parameters; 312 AudioParameters parameters;
313 if (core_audio_supported()) { 313 if (core_audio_supported()) {
314 hr = CoreAudioUtil::GetPreferredAudioParameters(device_id, false, 314 hr = CoreAudioUtil::GetPreferredAudioParameters(device_id, false,
315 &parameters); 315 &parameters);
316 } 316 }
317 317
318 if (FAILED(hr) || !parameters.IsValid()) { 318 if (FAILED(hr) || !parameters.IsValid()) {
319 // Windows Wave implementation is being used. 319 // Windows Wave implementation is being used.
320 parameters = AudioParameters( 320 parameters =
321 AudioParameters::AUDIO_PCM_LINEAR, CHANNEL_LAYOUT_STEREO, 48000, 16, 321 AudioParameters(AudioParameters::AUDIO_PCM_LINEAR,
322 kFallbackBufferSize, AudioParameters::NO_EFFECTS); 322 CHANNEL_LAYOUT_STEREO, 48000, 16, kFallbackBufferSize);
323 } 323 }
324 324
325 int user_buffer_size = GetUserBufferSize(); 325 int user_buffer_size = GetUserBufferSize();
326 if (user_buffer_size) { 326 if (user_buffer_size) {
327 parameters.Reset(parameters.format(), parameters.channel_layout(), 327 parameters.Reset(parameters.format(), parameters.channel_layout(),
328 parameters.channels(), parameters.sample_rate(), 328 parameters.channels(), parameters.sample_rate(),
329 parameters.bits_per_sample(), user_buffer_size); 329 parameters.bits_per_sample(), user_buffer_size);
330 } 330 }
331 331
332 return parameters; 332 return parameters;
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
510 buffer_size = input_params.frames_per_buffer(); 510 buffer_size = input_params.frames_per_buffer();
511 channel_layout = input_params.channel_layout(); 511 channel_layout = input_params.channel_layout();
512 sample_rate = input_params.sample_rate(); 512 sample_rate = input_params.sample_rate();
513 } 513 }
514 } 514 }
515 515
516 int user_buffer_size = GetUserBufferSize(); 516 int user_buffer_size = GetUserBufferSize();
517 if (user_buffer_size) 517 if (user_buffer_size)
518 buffer_size = user_buffer_size; 518 buffer_size = user_buffer_size;
519 519
520 return AudioParameters( 520 return AudioParameters(AudioParameters::AUDIO_PCM_LOW_LATENCY, channel_layout,
521 AudioParameters::AUDIO_PCM_LOW_LATENCY, channel_layout, 521 sample_rate, bits_per_sample, buffer_size,
522 sample_rate, bits_per_sample, buffer_size, effects); 522 std::vector<media::Point>(), effects);
523 } 523 }
524 524
525 AudioInputStream* AudioManagerWin::CreatePCMWaveInAudioInputStream( 525 AudioInputStream* AudioManagerWin::CreatePCMWaveInAudioInputStream(
526 const AudioParameters& params, 526 const AudioParameters& params,
527 const std::string& device_id) { 527 const std::string& device_id) {
528 std::string xp_device_id = device_id; 528 std::string xp_device_id = device_id;
529 if (device_id != AudioManagerBase::kDefaultDeviceId && 529 if (device_id != AudioManagerBase::kDefaultDeviceId &&
530 enumeration_type_ == kMMDeviceEnumeration) { 530 enumeration_type_ == kMMDeviceEnumeration) {
531 xp_device_id = ConvertToWinXPInputDeviceId(device_id); 531 xp_device_id = ConvertToWinXPInputDeviceId(device_id);
532 if (xp_device_id.empty()) { 532 if (xp_device_id.empty()) {
533 DLOG(ERROR) << "Cannot find a waveIn device which matches the device ID " 533 DLOG(ERROR) << "Cannot find a waveIn device which matches the device ID "
534 << device_id; 534 << device_id;
535 return NULL; 535 return NULL;
536 } 536 }
537 } 537 }
538 538
539 return new PCMWaveInAudioInputStream(this, params, kNumInputBuffers, 539 return new PCMWaveInAudioInputStream(this, params, kNumInputBuffers,
540 xp_device_id); 540 xp_device_id);
541 } 541 }
542 542
543 /// static 543 /// static
544 AudioManager* CreateAudioManager(AudioLogFactory* audio_log_factory) { 544 AudioManager* CreateAudioManager(AudioLogFactory* audio_log_factory) {
545 return new AudioManagerWin(audio_log_factory); 545 return new AudioManagerWin(audio_log_factory);
546 } 546 }
547 547
548 } // namespace media 548 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698