Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 |
| 11 #ifndef WEBRTC_AUDIO_DEVICE_AUDIO_DEVICE_BUFFER_H | 11 #ifndef WEBRTC_MODULES_AUDIO_DEVICE_AUDIO_DEVICE_BUFFER_H_ |
| 12 #define WEBRTC_AUDIO_DEVICE_AUDIO_DEVICE_BUFFER_H | 12 #define WEBRTC_MODULES_AUDIO_DEVICE_AUDIO_DEVICE_BUFFER_H_ |
| 13 | 13 |
| 14 #include "webrtc/base/criticalsection.h" | |
| 15 #include "webrtc/base/task_queue.h" | |
| 14 #include "webrtc/modules/audio_device/include/audio_device.h" | 16 #include "webrtc/modules/audio_device/include/audio_device.h" |
| 15 #include "webrtc/system_wrappers/include/file_wrapper.h" | 17 #include "webrtc/system_wrappers/include/file_wrapper.h" |
| 16 #include "webrtc/typedefs.h" | 18 #include "webrtc/typedefs.h" |
| 17 | 19 |
| 18 namespace webrtc { | 20 namespace webrtc { |
| 19 class CriticalSectionWrapper; | 21 class CriticalSectionWrapper; |
| 20 | 22 |
| 21 const uint32_t kPulsePeriodMs = 1000; | 23 const uint32_t kPulsePeriodMs = 1000; |
| 22 const size_t kMaxBufferSizeBytes = 3840; // 10ms in stereo @ 96kHz | 24 const size_t kMaxBufferSizeBytes = 3840; // 10ms in stereo @ 96kHz |
| 23 | 25 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 56 virtual int32_t GetPlayoutData(void* audioBuffer); | 58 virtual int32_t GetPlayoutData(void* audioBuffer); |
| 57 | 59 |
| 58 int32_t StartInputFileRecording(const char fileName[kAdmMaxFileNameSize]); | 60 int32_t StartInputFileRecording(const char fileName[kAdmMaxFileNameSize]); |
| 59 int32_t StopInputFileRecording(); | 61 int32_t StopInputFileRecording(); |
| 60 int32_t StartOutputFileRecording(const char fileName[kAdmMaxFileNameSize]); | 62 int32_t StartOutputFileRecording(const char fileName[kAdmMaxFileNameSize]); |
| 61 int32_t StopOutputFileRecording(); | 63 int32_t StopOutputFileRecording(); |
| 62 | 64 |
| 63 int32_t SetTypingStatus(bool typingStatus); | 65 int32_t SetTypingStatus(bool typingStatus); |
| 64 | 66 |
| 65 private: | 67 private: |
| 66 CriticalSectionWrapper& _critSect; | 68 // Posts the first delayed task in the task queue and starts the periodic |
| 67 CriticalSectionWrapper& _critSectCb; | 69 // timer. |
| 70 void StartTimer(); | |
| 71 | |
| 72 // Called periodically on the internal thread created by the TaskQueue. | |
| 73 // Members are only read and never modified by this method and all access is | |
| 74 // done without any locks. The stored data is only for logging purposes and | |
| 75 // minor deviations to to potential race issues are ignored. | |
| 76 // TODO(henrika): remove all usage of locks in this class, add thread checker | |
| 77 // and document the threading model. | |
| 78 void LogStats(); | |
| 79 | |
| 80 rtc::CriticalSection _critSect; | |
| 81 rtc::CriticalSection _critSectCb; | |
| 68 | 82 |
| 69 AudioTransport* _ptrCbAudioTransport; | 83 AudioTransport* _ptrCbAudioTransport; |
| 70 | 84 |
| 85 // Task queue posting delayed tasks periodically. Used as a timer and calls | |
| 86 // LogStats() in each task. | |
| 87 std::unique_ptr<rtc::TaskQueue> task_queue_; | |
|
stefan-webrtc
2016/07/07 15:22:14
Any point in allocating this dynamically?
henrika_webrtc
2016/07/08 12:46:48
Actually not. Will change.
| |
| 88 | |
| 89 // Ensures that the timer is only started once. | |
| 90 bool timer_has_started_; | |
| 91 | |
| 71 uint32_t _recSampleRate; | 92 uint32_t _recSampleRate; |
| 72 uint32_t _playSampleRate; | 93 uint32_t _playSampleRate; |
| 73 | 94 |
| 74 size_t _recChannels; | 95 size_t _recChannels; |
| 75 size_t _playChannels; | 96 size_t _playChannels; |
| 76 | 97 |
| 77 // selected recording channel (left/right/both) | 98 // selected recording channel (left/right/both) |
| 78 AudioDeviceModule::ChannelType _recChannel; | 99 AudioDeviceModule::ChannelType _recChannel; |
| 79 | 100 |
| 80 // 2 or 4 depending on mono or stereo | 101 // 2 or 4 depending on mono or stereo |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 100 | 121 |
| 101 uint32_t _currentMicLevel; | 122 uint32_t _currentMicLevel; |
| 102 uint32_t _newMicLevel; | 123 uint32_t _newMicLevel; |
| 103 | 124 |
| 104 bool _typingStatus; | 125 bool _typingStatus; |
| 105 | 126 |
| 106 int _playDelayMS; | 127 int _playDelayMS; |
| 107 int _recDelayMS; | 128 int _recDelayMS; |
| 108 int _clockDrift; | 129 int _clockDrift; |
| 109 int high_delay_counter_; | 130 int high_delay_counter_; |
| 131 | |
| 132 // Total number of recording callbacks where the source provides 10ms audio | |
| 133 // data each time. | |
| 134 uint64_t rec_callbacks_; | |
| 135 | |
| 136 // Total number of recording callbacks stored at the last timer task. | |
| 137 uint64_t last_rec_callbacks_; | |
| 138 | |
| 139 // Total number of playback callbacks where the sink asks for 10ms audio | |
| 140 // data each time. | |
| 141 uint64_t play_callbacks_; | |
| 142 | |
| 143 // Total number of playout callbacks stored at the last timer task. | |
| 144 uint64_t last_play_callbacks_; | |
| 145 | |
| 146 // Total number of recorded audio samples. | |
| 147 uint64_t rec_samples_; | |
| 148 | |
| 149 // Total number of recorded samples stored at the previous timer task. | |
| 150 uint64_t last_rec_samples_; | |
| 151 | |
| 152 // Total number of played audio samples. | |
| 153 uint64_t play_samples_; | |
| 154 | |
| 155 // Total number of played samples stored at the previous timer task. | |
| 156 uint64_t last_play_samples_; | |
| 110 }; | 157 }; |
| 111 | 158 |
| 112 } // namespace webrtc | 159 } // namespace webrtc |
| 113 | 160 |
| 114 #endif // WEBRTC_AUDIO_DEVICE_AUDIO_DEVICE_BUFFER_H | 161 #endif // WEBRTC_MODULES_AUDIO_DEVICE_AUDIO_DEVICE_BUFFER_H_ |
| OLD | NEW |