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_low_latency_input_win.h" | 5 #include "media/audio/win/audio_low_latency_input_win.h" |
6 | 6 |
7 #include <objbase.h> | 7 #include <objbase.h> |
8 | 8 |
9 #include <cmath> | 9 #include <cmath> |
10 #include <memory> | 10 #include <memory> |
(...skipping 510 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
521 } | 521 } |
522 | 522 |
523 // Retrieve the IMMDevice by using the specified role or the specified | 523 // Retrieve the IMMDevice by using the specified role or the specified |
524 // unique endpoint device-identification string. | 524 // unique endpoint device-identification string. |
525 | 525 |
526 if (device_id_ == AudioDeviceDescription::kDefaultDeviceId) { | 526 if (device_id_ == AudioDeviceDescription::kDefaultDeviceId) { |
527 // Retrieve the default capture audio endpoint for the specified role. | 527 // Retrieve the default capture audio endpoint for the specified role. |
528 // Note that, in Windows Vista, the MMDevice API supports device roles | 528 // Note that, in Windows Vista, the MMDevice API supports device roles |
529 // but the system-supplied user interface programs do not. | 529 // but the system-supplied user interface programs do not. |
530 hr = enumerator->GetDefaultAudioEndpoint(eCapture, eConsole, | 530 hr = enumerator->GetDefaultAudioEndpoint(eCapture, eConsole, |
531 endpoint_device_.Receive()); | 531 endpoint_device_.GetAddressOf()); |
532 } else if (device_id_ == AudioDeviceDescription::kCommunicationsDeviceId) { | 532 } else if (device_id_ == AudioDeviceDescription::kCommunicationsDeviceId) { |
533 hr = enumerator->GetDefaultAudioEndpoint(eCapture, eCommunications, | 533 hr = enumerator->GetDefaultAudioEndpoint(eCapture, eCommunications, |
534 endpoint_device_.Receive()); | 534 endpoint_device_.GetAddressOf()); |
535 } else if (device_id_ == AudioDeviceDescription::kLoopbackWithMuteDeviceId) { | 535 } else if (device_id_ == AudioDeviceDescription::kLoopbackWithMuteDeviceId) { |
536 // Capture the default playback stream. | 536 // Capture the default playback stream. |
537 hr = enumerator->GetDefaultAudioEndpoint(eRender, eConsole, | 537 hr = enumerator->GetDefaultAudioEndpoint(eRender, eConsole, |
538 endpoint_device_.Receive()); | 538 endpoint_device_.GetAddressOf()); |
539 | 539 |
540 endpoint_device_->Activate(__uuidof(IAudioEndpointVolume), CLSCTX_ALL, NULL, | 540 endpoint_device_->Activate(__uuidof(IAudioEndpointVolume), CLSCTX_ALL, NULL, |
541 &system_audio_volume_); | 541 &system_audio_volume_); |
542 } else if (device_id_ == AudioDeviceDescription::kLoopbackInputDeviceId) { | 542 } else if (device_id_ == AudioDeviceDescription::kLoopbackInputDeviceId) { |
543 // Capture the default playback stream. | 543 // Capture the default playback stream. |
544 hr = enumerator->GetDefaultAudioEndpoint(eRender, eConsole, | 544 hr = enumerator->GetDefaultAudioEndpoint(eRender, eConsole, |
545 endpoint_device_.Receive()); | 545 endpoint_device_.GetAddressOf()); |
546 } else { | 546 } else { |
547 hr = enumerator->GetDevice(base::UTF8ToUTF16(device_id_).c_str(), | 547 hr = enumerator->GetDevice(base::UTF8ToUTF16(device_id_).c_str(), |
548 endpoint_device_.Receive()); | 548 endpoint_device_.GetAddressOf()); |
549 } | 549 } |
550 | 550 |
551 if (FAILED(hr)) { | 551 if (FAILED(hr)) { |
552 open_result_ = OPEN_RESULT_NO_ENDPOINT; | 552 open_result_ = OPEN_RESULT_NO_ENDPOINT; |
553 return hr; | 553 return hr; |
554 } | 554 } |
555 | 555 |
556 // Verify that the audio endpoint device is active, i.e., the audio | 556 // Verify that the audio endpoint device is active, i.e., the audio |
557 // adapter that connects to the endpoint device is present and enabled. | 557 // adapter that connects to the endpoint device is present and enabled. |
558 DWORD state = DEVICE_STATE_DISABLED; | 558 DWORD state = DEVICE_STATE_DISABLED; |
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
828 OPEN_RESULT_MAX + 1); | 828 OPEN_RESULT_MAX + 1); |
829 } | 829 } |
830 | 830 |
831 double WASAPIAudioInputStream::ProvideInput(AudioBus* audio_bus, | 831 double WASAPIAudioInputStream::ProvideInput(AudioBus* audio_bus, |
832 uint32_t frames_delayed) { | 832 uint32_t frames_delayed) { |
833 fifo_->Consume()->CopyTo(audio_bus); | 833 fifo_->Consume()->CopyTo(audio_bus); |
834 return 1.0; | 834 return 1.0; |
835 } | 835 } |
836 | 836 |
837 } // namespace media | 837 } // namespace media |
OLD | NEW |