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

Side by Side Diff: modules/audio_device/win/audio_device_core_win.cc

Issue 3020493002: Remove AudioDeviceObserver and make ADM not inherit from the Module interface.
Patch Set: linux build error Created 3 years, 2 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 /* 1 /*
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after
457 _hSetCaptureVolumeEvent(NULL), 457 _hSetCaptureVolumeEvent(NULL),
458 _hMmTask(NULL), 458 _hMmTask(NULL),
459 _initialized(false), 459 _initialized(false),
460 _recording(false), 460 _recording(false),
461 _playing(false), 461 _playing(false),
462 _recIsInitialized(false), 462 _recIsInitialized(false),
463 _playIsInitialized(false), 463 _playIsInitialized(false),
464 _speakerIsInitialized(false), 464 _speakerIsInitialized(false),
465 _microphoneIsInitialized(false), 465 _microphoneIsInitialized(false),
466 _AGC(false), 466 _AGC(false),
467 _playWarning(0),
468 _playError(0),
469 _recWarning(0),
470 _recError(0),
471 _playBufDelay(80), 467 _playBufDelay(80),
472 _usingInputDeviceIndex(false), 468 _usingInputDeviceIndex(false),
473 _usingOutputDeviceIndex(false), 469 _usingOutputDeviceIndex(false),
474 _inputDevice(AudioDeviceModule::kDefaultCommunicationDevice), 470 _inputDevice(AudioDeviceModule::kDefaultCommunicationDevice),
475 _outputDevice(AudioDeviceModule::kDefaultCommunicationDevice), 471 _outputDevice(AudioDeviceModule::kDefaultCommunicationDevice),
476 _inputDeviceIndex(0), 472 _inputDeviceIndex(0),
477 _outputDeviceIndex(0), 473 _outputDeviceIndex(0),
478 _newMicLevel(0) { 474 _newMicLevel(0) {
479 LOG(LS_INFO) << __FUNCTION__ << " created"; 475 LOG(LS_INFO) << __FUNCTION__ << " created";
480 assert(_comInit.succeeded()); 476 assert(_comInit.succeeded());
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
678 // Init 674 // Init
679 // ---------------------------------------------------------------------------- 675 // ----------------------------------------------------------------------------
680 676
681 AudioDeviceGeneric::InitStatus AudioDeviceWindowsCore::Init() { 677 AudioDeviceGeneric::InitStatus AudioDeviceWindowsCore::Init() {
682 rtc::CritScope lock(&_critSect); 678 rtc::CritScope lock(&_critSect);
683 679
684 if (_initialized) { 680 if (_initialized) {
685 return InitStatus::OK; 681 return InitStatus::OK;
686 } 682 }
687 683
688 _playWarning = 0;
689 _playError = 0;
690 _recWarning = 0;
691 _recError = 0;
692
693 // Enumerate all audio rendering and capturing endpoint devices. 684 // Enumerate all audio rendering and capturing endpoint devices.
694 // Note that, some of these will not be able to select by the user. 685 // Note that, some of these will not be able to select by the user.
695 // The complete collection is for internal use only. 686 // The complete collection is for internal use only.
696 _EnumerateEndpointDevicesAll(eRender); 687 _EnumerateEndpointDevicesAll(eRender);
697 _EnumerateEndpointDevicesAll(eCapture); 688 _EnumerateEndpointDevicesAll(eCapture);
698 689
699 _initialized = true; 690 _initialized = true;
700 691
701 return InitStatus::OK; 692 return InitStatus::OK;
702 } 693 }
(...skipping 2351 matching lines...) Expand 10 before | Expand all | Expand 10 after
3054 3045
3055 // ---------------------------------------------------------------------------- 3046 // ----------------------------------------------------------------------------
3056 // Playing 3047 // Playing
3057 // ---------------------------------------------------------------------------- 3048 // ----------------------------------------------------------------------------
3058 3049
3059 bool AudioDeviceWindowsCore::Playing() const 3050 bool AudioDeviceWindowsCore::Playing() const
3060 { 3051 {
3061 return (_playing); 3052 return (_playing);
3062 } 3053 }
3063 3054
3064 // ----------------------------------------------------------------------------
3065 // PlayoutWarning
3066 // ----------------------------------------------------------------------------
3067
3068 bool AudioDeviceWindowsCore::PlayoutWarning() const
3069 {
3070 return ( _playWarning > 0);
3071 }
3072
3073 // ----------------------------------------------------------------------------
3074 // PlayoutError
3075 // ----------------------------------------------------------------------------
3076
3077 bool AudioDeviceWindowsCore::PlayoutError() const
3078 {
3079 return ( _playError > 0);
3080 }
3081
3082 // ----------------------------------------------------------------------------
3083 // RecordingWarning
3084 // ----------------------------------------------------------------------------
3085
3086 bool AudioDeviceWindowsCore::RecordingWarning() const
3087 {
3088 return ( _recWarning > 0);
3089 }
3090
3091 // ----------------------------------------------------------------------------
3092 // RecordingError
3093 // ----------------------------------------------------------------------------
3094
3095 bool AudioDeviceWindowsCore::RecordingError() const
3096 {
3097 return ( _recError > 0);
3098 }
3099
3100 // ----------------------------------------------------------------------------
3101 // ClearPlayoutWarning
3102 // ----------------------------------------------------------------------------
3103
3104 void AudioDeviceWindowsCore::ClearPlayoutWarning()
3105 {
3106 _playWarning = 0;
3107 }
3108
3109 // ----------------------------------------------------------------------------
3110 // ClearPlayoutError
3111 // ----------------------------------------------------------------------------
3112
3113 void AudioDeviceWindowsCore::ClearPlayoutError()
3114 {
3115 _playError = 0;
3116 }
3117
3118 // ----------------------------------------------------------------------------
3119 // ClearRecordingWarning
3120 // ----------------------------------------------------------------------------
3121
3122 void AudioDeviceWindowsCore::ClearRecordingWarning()
3123 {
3124 _recWarning = 0;
3125 }
3126
3127 // ----------------------------------------------------------------------------
3128 // ClearRecordingError
3129 // ----------------------------------------------------------------------------
3130
3131 void AudioDeviceWindowsCore::ClearRecordingError()
3132 {
3133 _recError = 0;
3134 }
3135
3136 // ============================================================================ 3055 // ============================================================================
3137 // Private Methods 3056 // Private Methods
3138 // ============================================================================ 3057 // ============================================================================
3139 3058
3140 // ---------------------------------------------------------------------------- 3059 // ----------------------------------------------------------------------------
3141 // [static] WSAPIRenderThread 3060 // [static] WSAPIRenderThread
3142 // ---------------------------------------------------------------------------- 3061 // ----------------------------------------------------------------------------
3143 3062
3144 DWORD WINAPI AudioDeviceWindowsCore::WSAPIRenderThread(LPVOID context) 3063 DWORD WINAPI AudioDeviceWindowsCore::WSAPIRenderThread(LPVOID context)
3145 { 3064 {
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after
3515 if (FAILED(hr)) 3434 if (FAILED(hr))
3516 { 3435 {
3517 _TraceCOMError(hr); 3436 _TraceCOMError(hr);
3518 } 3437 }
3519 hr = _ptrClientOut->Reset(); 3438 hr = _ptrClientOut->Reset();
3520 if (FAILED(hr)) 3439 if (FAILED(hr))
3521 { 3440 {
3522 _TraceCOMError(hr); 3441 _TraceCOMError(hr);
3523 } 3442 }
3524 } 3443 }
3525 // Trigger callback from module process thread
3526 _playError = 1;
3527 LOG(LS_ERROR) 3444 LOG(LS_ERROR)
3528 << "kPlayoutError message posted: rendering thread has ended" 3445 << "Playout error: rendering thread has ended pre-maturely";
3529 << " pre-maturely";
3530 } 3446 }
3531 else 3447 else
3532 { 3448 {
3533 LOG(LS_VERBOSE) << "_Rendering thread is now terminated properly"; 3449 LOG(LS_VERBOSE) << "_Rendering thread is now terminated properly";
3534 } 3450 }
3535 3451
3536 _UnLock(); 3452 _UnLock();
3537 3453
3538 return (DWORD)hr; 3454 return (DWORD)hr;
3539 } 3455 }
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
3702 break; 3618 break;
3703 } 3619 }
3704 } 3620 }
3705 } 3621 }
3706 // ---------------------------- THREAD LOOP ---------------------------- << 3622 // ---------------------------- THREAD LOOP ---------------------------- <<
3707 3623
3708 RevertCaptureThreadPriority(); 3624 RevertCaptureThreadPriority();
3709 3625
3710 if (FAILED(hr)) 3626 if (FAILED(hr))
3711 { 3627 {
3712 // Trigger callback from module process thread 3628 LOG(LS_ERROR)
3713 _recError = 1; 3629 << "Recording error: capturing thread has ended prematurely";
3714 LOG(LS_ERROR) << "kRecordingError message posted: capturing thread has"
3715 << " ended prematurely";
3716 } 3630 }
3717 else 3631 else
3718 { 3632 {
3719 LOG(LS_VERBOSE) << "Capturing thread is now terminated properly"; 3633 LOG(LS_VERBOSE) << "Capturing thread is now terminated properly";
3720 } 3634 }
3721 3635
3722 return hr; 3636 return hr;
3723 } 3637 }
3724 3638
3725 3639
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after
4005 { 3919 {
4006 _TraceCOMError(hr); 3920 _TraceCOMError(hr);
4007 } 3921 }
4008 hr = _ptrClientIn->Reset(); 3922 hr = _ptrClientIn->Reset();
4009 if (FAILED(hr)) 3923 if (FAILED(hr))
4010 { 3924 {
4011 _TraceCOMError(hr); 3925 _TraceCOMError(hr);
4012 } 3926 }
4013 } 3927 }
4014 3928
4015 // Trigger callback from module process thread
4016 _recError = 1;
4017 LOG(LS_ERROR) 3929 LOG(LS_ERROR)
4018 << "kRecordingError message posted: capturing thread has ended" 3930 << "Recording error: capturing thread has ended pre-maturely";
4019 << " pre-maturely";
4020 } 3931 }
4021 else 3932 else
4022 { 3933 {
4023 LOG(LS_VERBOSE) << "_Capturing thread is now terminated properly"; 3934 LOG(LS_VERBOSE) << "_Capturing thread is now terminated properly";
4024 } 3935 }
4025 3936
4026 SAFE_RELEASE(_ptrClientIn); 3937 SAFE_RELEASE(_ptrClientIn);
4027 SAFE_RELEASE(_ptrCaptureClient); 3938 SAFE_RELEASE(_ptrCaptureClient);
4028 3939
4029 _UnLock(); 3940 _UnLock();
(...skipping 930 matching lines...) Expand 10 before | Expand all | Expand 10 after
4960 int key_down = 0; 4871 int key_down = 0;
4961 for (int key = VK_SPACE; key < VK_NUMLOCK; key++) { 4872 for (int key = VK_SPACE; key < VK_NUMLOCK; key++) {
4962 short res = GetAsyncKeyState(key); 4873 short res = GetAsyncKeyState(key);
4963 key_down |= res & 0x1; // Get the LSB 4874 key_down |= res & 0x1; // Get the LSB
4964 } 4875 }
4965 return (key_down > 0); 4876 return (key_down > 0);
4966 } 4877 }
4967 } // namespace webrtc 4878 } // namespace webrtc
4968 4879
4969 #endif // WEBRTC_WINDOWS_CORE_AUDIO_BUILD 4880 #endif // WEBRTC_WINDOWS_CORE_AUDIO_BUILD
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698