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 |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 // valid implementation. Investigate the possibility to either remove them | 66 // valid implementation. Investigate the possibility to either remove them |
67 // or add a proper implementation if needed. | 67 // or add a proper implementation if needed. |
68 int32_t StartInputFileRecording(const char fileName[kAdmMaxFileNameSize]); | 68 int32_t StartInputFileRecording(const char fileName[kAdmMaxFileNameSize]); |
69 int32_t StopInputFileRecording(); | 69 int32_t StopInputFileRecording(); |
70 int32_t StartOutputFileRecording(const char fileName[kAdmMaxFileNameSize]); | 70 int32_t StartOutputFileRecording(const char fileName[kAdmMaxFileNameSize]); |
71 int32_t StopOutputFileRecording(); | 71 int32_t StopOutputFileRecording(); |
72 | 72 |
73 int32_t SetTypingStatus(bool typing_status); | 73 int32_t SetTypingStatus(bool typing_status); |
74 | 74 |
75 private: | 75 private: |
76 void AllocatePlayoutBufferIfNeeded(); | 76 // Playout and recording parameters can change on the fly. e.g. at device |
77 void AllocateRecordingBufferIfNeeded(); | 77 // switch. These methods ensures that the callback methods always use the |
| 78 // latest parameters. |
| 79 void UpdatePlayoutParameters(); |
| 80 void UpdateRecordingParameters(); |
78 | 81 |
79 // Posts the first delayed task in the task queue and starts the periodic | 82 // Posts the first delayed task in the task queue and starts the periodic |
80 // timer. | 83 // timer. |
81 void StartTimer(); | 84 void StartTimer(); |
82 | 85 |
83 // Called periodically on the internal thread created by the TaskQueue. | 86 // Called periodically on the internal thread created by the TaskQueue. |
84 void LogStats(); | 87 void LogStats(); |
85 | 88 |
86 // Updates counters in each play/record callback but does it on the task | 89 // Updates counters in each play/record callback but does it on the task |
87 // queue to ensure that they can be read by LogStats() without any locks since | 90 // queue to ensure that they can be read by LogStats() without any locks since |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 // Number of bytes per audio sample (2 or 4). | 127 // Number of bytes per audio sample (2 or 4). |
125 size_t rec_bytes_per_sample_; | 128 size_t rec_bytes_per_sample_; |
126 size_t play_bytes_per_sample_; | 129 size_t play_bytes_per_sample_; |
127 | 130 |
128 // Number of audio samples/bytes per 10ms. | 131 // Number of audio samples/bytes per 10ms. |
129 size_t rec_samples_per_10ms_; | 132 size_t rec_samples_per_10ms_; |
130 size_t rec_bytes_per_10ms_; | 133 size_t rec_bytes_per_10ms_; |
131 size_t play_samples_per_10ms_; | 134 size_t play_samples_per_10ms_; |
132 size_t play_bytes_per_10ms_; | 135 size_t play_bytes_per_10ms_; |
133 | 136 |
134 // Buffer used for recorded audio samples. Size is given by | 137 // Buffer used for recorded audio samples. Size is currently fixed |
135 // |rec_bytes_per_10ms_| and the buffer is allocated in InitRecording() on the | 138 // but it should be changed to be dynamic and correspond to |
136 // main/creating thread. | 139 // |play_bytes_per_10ms_|. TODO(henrika): avoid using fixed (max) size. |
137 std::unique_ptr<int8_t[]> rec_buffer_; | 140 std::unique_ptr<int8_t[]> rec_buffer_; |
138 | 141 |
139 // Buffer used for audio samples to be played out. Size is given by | 142 // Buffer used for audio samples to be played out. Size is currently fixed |
140 // |play_bytes_per_10ms_| and the buffer is allocated in InitPlayout() on the | 143 // but it should be changed to be dynamic and correspond to |
141 // main/creating thread. | 144 // |play_bytes_per_10ms_|. TODO(henrika): avoid using fixed (max) size. |
142 std::unique_ptr<int8_t[]> play_buffer_; | 145 std::unique_ptr<int8_t[]> play_buffer_; |
143 | 146 |
144 // AGC parameters. | 147 // AGC parameters. |
145 uint32_t current_mic_level_; | 148 uint32_t current_mic_level_; |
146 uint32_t new_mic_level_; | 149 uint32_t new_mic_level_; |
147 | 150 |
148 // Contains true of a key-press has been detected. | 151 // Contains true of a key-press has been detected. |
149 bool typing_status_; | 152 bool typing_status_; |
150 | 153 |
151 // Delay values used by the AEC. | 154 // Delay values used by the AEC. |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 // milliseconds) between two successive playout callbacks, and the stored | 197 // milliseconds) between two successive playout callbacks, and the stored |
195 // value is the number of times a given time difference was found. | 198 // value is the number of times a given time difference was found. |
196 // Writing to the array is done without a lock since it is only read once at | 199 // Writing to the array is done without a lock since it is only read once at |
197 // destruction when no audio is running. | 200 // destruction when no audio is running. |
198 uint32_t playout_diff_times_[kMaxDeltaTimeInMs + 1] = {0}; | 201 uint32_t playout_diff_times_[kMaxDeltaTimeInMs + 1] = {0}; |
199 }; | 202 }; |
200 | 203 |
201 } // namespace webrtc | 204 } // namespace webrtc |
202 | 205 |
203 #endif // WEBRTC_MODULES_AUDIO_DEVICE_AUDIO_DEVICE_BUFFER_H_ | 206 #endif // WEBRTC_MODULES_AUDIO_DEVICE_AUDIO_DEVICE_BUFFER_H_ |
OLD | NEW |