| 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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 int32_t PlayoutSampleRate() const; | 53 int32_t PlayoutSampleRate() const; |
| 54 | 54 |
| 55 int32_t SetRecordingChannels(size_t channels); | 55 int32_t SetRecordingChannels(size_t channels); |
| 56 int32_t SetPlayoutChannels(size_t channels); | 56 int32_t SetPlayoutChannels(size_t channels); |
| 57 size_t RecordingChannels() const; | 57 size_t RecordingChannels() const; |
| 58 size_t PlayoutChannels() const; | 58 size_t PlayoutChannels() const; |
| 59 int32_t SetRecordingChannel(const AudioDeviceModule::ChannelType channel); | 59 int32_t SetRecordingChannel(const AudioDeviceModule::ChannelType channel); |
| 60 int32_t RecordingChannel(AudioDeviceModule::ChannelType& channel) const; | 60 int32_t RecordingChannel(AudioDeviceModule::ChannelType& channel) const; |
| 61 | 61 |
| 62 virtual int32_t SetRecordedBuffer(const void* audio_buffer, | 62 virtual int32_t SetRecordedBuffer(const void* audio_buffer, |
| 63 size_t num_samples); | 63 size_t samples_per_channel); |
| 64 int32_t SetCurrentMicLevel(uint32_t level); | 64 int32_t SetCurrentMicLevel(uint32_t level); |
| 65 virtual void SetVQEData(int play_delay_ms, int rec_delay_ms, int clock_drift); | 65 virtual void SetVQEData(int play_delay_ms, int rec_delay_ms, int clock_drift); |
| 66 virtual int32_t DeliverRecordedData(); | 66 virtual int32_t DeliverRecordedData(); |
| 67 uint32_t NewMicLevel() const; | 67 uint32_t NewMicLevel() const; |
| 68 | 68 |
| 69 virtual int32_t RequestPlayoutData(size_t num_samples); | 69 virtual int32_t RequestPlayoutData(size_t samples_per_channel); |
| 70 virtual int32_t GetPlayoutData(void* audio_buffer); | 70 virtual int32_t GetPlayoutData(void* audio_buffer); |
| 71 | 71 |
| 72 // TODO(henrika): these methods should not be used and does not contain any | 72 // TODO(henrika): these methods should not be used and does not contain any |
| 73 // valid implementation. Investigate the possibility to either remove them | 73 // valid implementation. Investigate the possibility to either remove them |
| 74 // or add a proper implementation if needed. | 74 // or add a proper implementation if needed. |
| 75 int32_t StartInputFileRecording(const char fileName[kAdmMaxFileNameSize]); | 75 int32_t StartInputFileRecording(const char fileName[kAdmMaxFileNameSize]); |
| 76 int32_t StopInputFileRecording(); | 76 int32_t StopInputFileRecording(); |
| 77 int32_t StartOutputFileRecording(const char fileName[kAdmMaxFileNameSize]); | 77 int32_t StartOutputFileRecording(const char fileName[kAdmMaxFileNameSize]); |
| 78 int32_t StopOutputFileRecording(); | 78 int32_t StopOutputFileRecording(); |
| 79 | 79 |
| 80 int32_t SetTypingStatus(bool typing_status); | 80 int32_t SetTypingStatus(bool typing_status); |
| 81 | 81 |
| 82 private: | 82 private: |
| 83 // Starts/stops periodic logging of audio stats. | 83 // Starts/stops periodic logging of audio stats. |
| 84 void StartPeriodicLogging(); | 84 void StartPeriodicLogging(); |
| 85 void StopPeriodicLogging(); | 85 void StopPeriodicLogging(); |
| 86 | 86 |
| 87 // Called periodically on the internal thread created by the TaskQueue. | 87 // Called periodically on the internal thread created by the TaskQueue. |
| 88 // Updates some stats but dooes it on the task queue to ensure that access of | 88 // Updates some stats but dooes it on the task queue to ensure that access of |
| 89 // members is serialized hence avoiding usage of locks. | 89 // members is serialized hence avoiding usage of locks. |
| 90 // state = LOG_START => members are initialized and the timer starts. | 90 // state = LOG_START => members are initialized and the timer starts. |
| 91 // state = LOG_STOP => no logs are printed and the timer stops. | 91 // state = LOG_STOP => no logs are printed and the timer stops. |
| 92 // state = LOG_ACTIVE => logs are printed and the timer is kept alive. | 92 // state = LOG_ACTIVE => logs are printed and the timer is kept alive. |
| 93 void LogStats(LogState state); | 93 void LogStats(LogState state); |
| 94 | 94 |
| 95 // Updates counters in each play/record callback but does it on the task | 95 // Updates counters in each play/record callback but does it on the task |
| 96 // queue to ensure that they can be read by LogStats() without any locks since | 96 // queue to ensure that they can be read by LogStats() without any locks since |
| 97 // each task is serialized by the task queue. | 97 // each task is serialized by the task queue. |
| 98 void UpdateRecStats(int16_t max_abs, size_t num_samples); | 98 void UpdateRecStats(int16_t max_abs, size_t samples_per_channel); |
| 99 void UpdatePlayStats(int16_t max_abs, size_t num_samples); | 99 void UpdatePlayStats(int16_t max_abs, size_t samples_per_channel); |
| 100 | 100 |
| 101 // Clears all members tracking stats for recording and playout. | 101 // Clears all members tracking stats for recording and playout. |
| 102 // These methods both run on the task queue. | 102 // These methods both run on the task queue. |
| 103 void ResetRecStats(); | 103 void ResetRecStats(); |
| 104 void ResetPlayStats(); | 104 void ResetPlayStats(); |
| 105 | 105 |
| 106 // This object lives on the main (creating) thread and most methods are | 106 // This object lives on the main (creating) thread and most methods are |
| 107 // called on that same thread. When audio has started some methods will be | 107 // called on that same thread. When audio has started some methods will be |
| 108 // called on either a native audio thread for playout or a native thread for | 108 // called on either a native audio thread for playout or a native thread for |
| 109 // recording. Some members are not annotated since they are "protected by | 109 // recording. Some members are not annotated since they are "protected by |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 size_t rec_channels_; | 147 size_t rec_channels_; |
| 148 size_t play_channels_; | 148 size_t play_channels_; |
| 149 | 149 |
| 150 // Keeps track of if playout/recording are active or not. A combination | 150 // Keeps track of if playout/recording are active or not. A combination |
| 151 // of these states are used to determine when to start and stop the timer. | 151 // of these states are used to determine when to start and stop the timer. |
| 152 // Only used on the creating thread and not used to control any media flow. | 152 // Only used on the creating thread and not used to control any media flow. |
| 153 bool playing_ ACCESS_ON(main_thread_checker_); | 153 bool playing_ ACCESS_ON(main_thread_checker_); |
| 154 bool recording_ ACCESS_ON(main_thread_checker_); | 154 bool recording_ ACCESS_ON(main_thread_checker_); |
| 155 | 155 |
| 156 // Buffer used for audio samples to be played out. Size can be changed | 156 // Buffer used for audio samples to be played out. Size can be changed |
| 157 // dynamically. | 157 // dynamically. The 16-bit samples are interleaved, hence the size is |
| 158 rtc::Buffer play_buffer_ ACCESS_ON(playout_thread_checker_); | 158 // proportional to the number of channels. |
| 159 rtc::BufferT<int16_t> play_buffer_ ACCESS_ON(playout_thread_checker_); |
| 159 | 160 |
| 160 // Byte buffer used for recorded audio samples. Size can be changed | 161 // Byte buffer used for recorded audio samples. Size can be changed |
| 161 // dynamically. | 162 // dynamically. |
| 162 rtc::Buffer rec_buffer_ ACCESS_ON(recording_thread_checker_); | 163 rtc::BufferT<int16_t> rec_buffer_ ACCESS_ON(recording_thread_checker_); |
| 163 | 164 |
| 164 // AGC parameters. | 165 // AGC parameters. |
| 165 #if !defined(WEBRTC_WIN) | 166 #if !defined(WEBRTC_WIN) |
| 166 uint32_t current_mic_level_ ACCESS_ON(recording_thread_checker_); | 167 uint32_t current_mic_level_ ACCESS_ON(recording_thread_checker_); |
| 167 #else | 168 #else |
| 168 // Windows uses a dedicated thread for volume APIs. | 169 // Windows uses a dedicated thread for volume APIs. |
| 169 uint32_t current_mic_level_; | 170 uint32_t current_mic_level_; |
| 170 #endif | 171 #endif |
| 171 uint32_t new_mic_level_ ACCESS_ON(recording_thread_checker_); | 172 uint32_t new_mic_level_ ACCESS_ON(recording_thread_checker_); |
| 172 | 173 |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 231 uint64_t rec_start_time_ ACCESS_ON(main_thread_checker_); | 232 uint64_t rec_start_time_ ACCESS_ON(main_thread_checker_); |
| 232 | 233 |
| 233 // Set to true at construction and modified to false as soon as one audio- | 234 // Set to true at construction and modified to false as soon as one audio- |
| 234 // level estimate larger than zero is detected. | 235 // level estimate larger than zero is detected. |
| 235 bool only_silence_recorded_; | 236 bool only_silence_recorded_; |
| 236 }; | 237 }; |
| 237 | 238 |
| 238 } // namespace webrtc | 239 } // namespace webrtc |
| 239 | 240 |
| 240 #endif // WEBRTC_MODULES_AUDIO_DEVICE_AUDIO_DEVICE_BUFFER_H_ | 241 #endif // WEBRTC_MODULES_AUDIO_DEVICE_AUDIO_DEVICE_BUFFER_H_ |
| OLD | NEW |