| 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" |
| 16 #include "webrtc/base/thread_checker.h" |
| 14 #include "webrtc/modules/audio_device/include/audio_device.h" | 17 #include "webrtc/modules/audio_device/include/audio_device.h" |
| 15 #include "webrtc/system_wrappers/include/file_wrapper.h" | 18 #include "webrtc/system_wrappers/include/file_wrapper.h" |
| 16 #include "webrtc/typedefs.h" | 19 #include "webrtc/typedefs.h" |
| 17 | 20 |
| 18 namespace webrtc { | 21 namespace webrtc { |
| 19 class CriticalSectionWrapper; | 22 class CriticalSectionWrapper; |
| 20 | 23 |
| 21 const uint32_t kPulsePeriodMs = 1000; | 24 const uint32_t kPulsePeriodMs = 1000; |
| 22 const size_t kMaxBufferSizeBytes = 3840; // 10ms in stereo @ 96kHz | 25 const size_t kMaxBufferSizeBytes = 3840; // 10ms in stereo @ 96kHz |
| 23 | 26 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 virtual int32_t GetPlayoutData(void* audioBuffer); | 59 virtual int32_t GetPlayoutData(void* audioBuffer); |
| 57 | 60 |
| 58 int32_t StartInputFileRecording(const char fileName[kAdmMaxFileNameSize]); | 61 int32_t StartInputFileRecording(const char fileName[kAdmMaxFileNameSize]); |
| 59 int32_t StopInputFileRecording(); | 62 int32_t StopInputFileRecording(); |
| 60 int32_t StartOutputFileRecording(const char fileName[kAdmMaxFileNameSize]); | 63 int32_t StartOutputFileRecording(const char fileName[kAdmMaxFileNameSize]); |
| 61 int32_t StopOutputFileRecording(); | 64 int32_t StopOutputFileRecording(); |
| 62 | 65 |
| 63 int32_t SetTypingStatus(bool typingStatus); | 66 int32_t SetTypingStatus(bool typingStatus); |
| 64 | 67 |
| 65 private: | 68 private: |
| 66 CriticalSectionWrapper& _critSect; | 69 // Posts the first delayed task in the task queue and starts the periodic |
| 67 CriticalSectionWrapper& _critSectCb; | 70 // timer. |
| 71 void StartTimer(); |
| 72 |
| 73 // Called periodically on the internal thread created by the TaskQueue. |
| 74 void LogStats(); |
| 75 |
| 76 // Updates counters in each play/record callback but does it on the task |
| 77 // queue to ensure that they can be read by LogStats() without any locks since |
| 78 // each task is serialized by the task queue. |
| 79 void UpdateRecStats(int num_samples); |
| 80 void UpdatePlayStats(int num_samples); |
| 81 |
| 82 // Ensures that methods are called on the same thread as the thread that |
| 83 // creates this object. |
| 84 rtc::ThreadChecker thread_checker_; |
| 85 |
| 86 rtc::CriticalSection _critSect; |
| 87 rtc::CriticalSection _critSectCb; |
| 68 | 88 |
| 69 AudioTransport* _ptrCbAudioTransport; | 89 AudioTransport* _ptrCbAudioTransport; |
| 70 | 90 |
| 91 // Task queue used to invoke LogStats() periodically. Tasks are executed on a |
| 92 // worker thread but it does not necessarily have to be the same thread for |
| 93 // each task. |
| 94 rtc::TaskQueue task_queue_; |
| 95 |
| 96 // Ensures that the timer is only started once. |
| 97 bool timer_has_started_; |
| 98 |
| 71 uint32_t _recSampleRate; | 99 uint32_t _recSampleRate; |
| 72 uint32_t _playSampleRate; | 100 uint32_t _playSampleRate; |
| 73 | 101 |
| 74 size_t _recChannels; | 102 size_t _recChannels; |
| 75 size_t _playChannels; | 103 size_t _playChannels; |
| 76 | 104 |
| 77 // selected recording channel (left/right/both) | 105 // selected recording channel (left/right/both) |
| 78 AudioDeviceModule::ChannelType _recChannel; | 106 AudioDeviceModule::ChannelType _recChannel; |
| 79 | 107 |
| 80 // 2 or 4 depending on mono or stereo | 108 // 2 or 4 depending on mono or stereo |
| (...skipping 19 matching lines...) Expand all Loading... |
| 100 | 128 |
| 101 uint32_t _currentMicLevel; | 129 uint32_t _currentMicLevel; |
| 102 uint32_t _newMicLevel; | 130 uint32_t _newMicLevel; |
| 103 | 131 |
| 104 bool _typingStatus; | 132 bool _typingStatus; |
| 105 | 133 |
| 106 int _playDelayMS; | 134 int _playDelayMS; |
| 107 int _recDelayMS; | 135 int _recDelayMS; |
| 108 int _clockDrift; | 136 int _clockDrift; |
| 109 int high_delay_counter_; | 137 int high_delay_counter_; |
| 138 |
| 139 // Counts number of times LogStats() has been called. |
| 140 size_t num_stat_reports_; |
| 141 |
| 142 // Total number of recording callbacks where the source provides 10ms audio |
| 143 // data each time. |
| 144 uint64_t rec_callbacks_; |
| 145 |
| 146 // Total number of recording callbacks stored at the last timer task. |
| 147 uint64_t last_rec_callbacks_; |
| 148 |
| 149 // Total number of playback callbacks where the sink asks for 10ms audio |
| 150 // data each time. |
| 151 uint64_t play_callbacks_; |
| 152 |
| 153 // Total number of playout callbacks stored at the last timer task. |
| 154 uint64_t last_play_callbacks_; |
| 155 |
| 156 // Total number of recorded audio samples. |
| 157 uint64_t rec_samples_; |
| 158 |
| 159 // Total number of recorded samples stored at the previous timer task. |
| 160 uint64_t last_rec_samples_; |
| 161 |
| 162 // Total number of played audio samples. |
| 163 uint64_t play_samples_; |
| 164 |
| 165 // Total number of played samples stored at the previous timer task. |
| 166 uint64_t last_play_samples_; |
| 110 }; | 167 }; |
| 111 | 168 |
| 112 } // namespace webrtc | 169 } // namespace webrtc |
| 113 | 170 |
| 114 #endif // WEBRTC_AUDIO_DEVICE_AUDIO_DEVICE_BUFFER_H | 171 #endif // WEBRTC_MODULES_AUDIO_DEVICE_AUDIO_DEVICE_BUFFER_H_ |
| OLD | NEW |