niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 1 | /* |
andrew@webrtc.org | 6f9f817 | 2012-03-06 19:03:39 +0000 | [diff] [blame] | 2 | * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 3 | * |
| 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 |
| 6 | * tree. An additional intellectual property rights grant can be found |
| 7 | * in the file PATENTS. All contributing project authors may |
| 8 | * be found in the AUTHORS file in the root of the source tree. |
| 9 | */ |
| 10 | |
pbos@webrtc.org | 788acd1 | 2014-12-15 09:41:24 +0000 | [diff] [blame] | 11 | #ifndef WEBRTC_MODULES_AUDIO_PROCESSING_AUDIO_PROCESSING_IMPL_H_ |
| 12 | #define WEBRTC_MODULES_AUDIO_PROCESSING_AUDIO_PROCESSING_IMPL_H_ |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 13 | |
| 14 | #include <list> |
ajm@google.com | 808e0e0 | 2011-08-03 21:08:51 +0000 | [diff] [blame] | 15 | #include <string> |
Michael Graczyk | 86c6d33 | 2015-07-23 11:41:39 -0700 | [diff] [blame] | 16 | #include <vector> |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 17 | |
peah | df3efa8 | 2015-11-28 12:35:15 -0800 | [diff] [blame] | 18 | #include "webrtc/base/criticalsection.h" |
kwiberg@webrtc.org | 00b8f6b | 2015-02-26 14:34:55 +0000 | [diff] [blame] | 19 | #include "webrtc/base/scoped_ptr.h" |
pbos@webrtc.org | 788acd1 | 2014-12-15 09:41:24 +0000 | [diff] [blame] | 20 | #include "webrtc/base/thread_annotations.h" |
peah | df3efa8 | 2015-11-28 12:35:15 -0800 | [diff] [blame] | 21 | #include "webrtc/modules/audio_processing/audio_buffer.h" |
Michael Graczyk | dfa3605 | 2015-03-25 16:37:27 -0700 | [diff] [blame] | 22 | #include "webrtc/modules/audio_processing/include/audio_processing.h" |
peah | df3efa8 | 2015-11-28 12:35:15 -0800 | [diff] [blame] | 23 | #include "webrtc/system_wrappers/include/file_wrapper.h" |
| 24 | |
| 25 | #ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP |
| 26 | // Files generated at build-time by the protobuf compiler. |
| 27 | #ifdef WEBRTC_ANDROID_PLATFORM_BUILD |
| 28 | #include "external/webrtc/webrtc/modules/audio_processing/debug.pb.h" |
| 29 | #else |
| 30 | #include "webrtc/audio_processing/debug.pb.h" |
| 31 | #endif |
| 32 | #endif // WEBRTC_AUDIOPROC_DEBUG_DUMP |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 33 | |
| 34 | namespace webrtc { |
andrew@webrtc.org | ddbb8a2 | 2014-04-22 21:00:04 +0000 | [diff] [blame] | 35 | |
pbos@webrtc.org | 788acd1 | 2014-12-15 09:41:24 +0000 | [diff] [blame] | 36 | class AgcManagerDirect; |
ekmeyerson | 60d9b33 | 2015-08-14 10:35:55 -0700 | [diff] [blame] | 37 | class AudioConverter; |
Michael Graczyk | dfa3605 | 2015-03-25 16:37:27 -0700 | [diff] [blame] | 38 | |
| 39 | template<typename T> |
| 40 | class Beamformer; |
| 41 | |
andrew@webrtc.org | 56e4a05 | 2014-02-27 22:23:17 +0000 | [diff] [blame] | 42 | class EchoCancellationImpl; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 43 | class EchoControlMobileImpl; |
| 44 | class GainControlImpl; |
pbos@webrtc.org | 788acd1 | 2014-12-15 09:41:24 +0000 | [diff] [blame] | 45 | class GainControlForNewAgc; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 46 | class HighPassFilterImpl; |
| 47 | class LevelEstimatorImpl; |
| 48 | class NoiseSuppressionImpl; |
| 49 | class ProcessingComponent; |
pbos@webrtc.org | 788acd1 | 2014-12-15 09:41:24 +0000 | [diff] [blame] | 50 | class TransientSuppressor; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 51 | class VoiceDetectionImpl; |
ekmeyerson | 60d9b33 | 2015-08-14 10:35:55 -0700 | [diff] [blame] | 52 | class IntelligibilityEnhancer; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 53 | |
| 54 | class AudioProcessingImpl : public AudioProcessing { |
| 55 | public: |
peah | df3efa8 | 2015-11-28 12:35:15 -0800 | [diff] [blame] | 56 | // Methods forcing APM to run in a single-threaded manner. |
| 57 | // Acquires both the render and capture locks. |
andrew@webrtc.org | e84978f | 2014-01-25 02:09:06 +0000 | [diff] [blame] | 58 | explicit AudioProcessingImpl(const Config& config); |
Michael Graczyk | dfa3605 | 2015-03-25 16:37:27 -0700 | [diff] [blame] | 59 | // AudioProcessingImpl takes ownership of beamformer. |
| 60 | AudioProcessingImpl(const Config& config, Beamformer<float>* beamformer); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 61 | virtual ~AudioProcessingImpl(); |
kjellander@webrtc.org | 14665ff | 2015-03-04 12:58:35 +0000 | [diff] [blame] | 62 | int Initialize() override; |
| 63 | int Initialize(int input_sample_rate_hz, |
| 64 | int output_sample_rate_hz, |
| 65 | int reverse_sample_rate_hz, |
| 66 | ChannelLayout input_layout, |
| 67 | ChannelLayout output_layout, |
| 68 | ChannelLayout reverse_layout) override; |
Michael Graczyk | 86c6d33 | 2015-07-23 11:41:39 -0700 | [diff] [blame] | 69 | int Initialize(const ProcessingConfig& processing_config) override; |
kjellander@webrtc.org | 14665ff | 2015-03-04 12:58:35 +0000 | [diff] [blame] | 70 | void SetExtraOptions(const Config& config) override; |
peah | df3efa8 | 2015-11-28 12:35:15 -0800 | [diff] [blame] | 71 | void UpdateHistogramsOnCallEnd() override; |
| 72 | int StartDebugRecording(const char filename[kMaxFilenameSize]) override; |
| 73 | int StartDebugRecording(FILE* handle) override; |
| 74 | int StartDebugRecordingForPlatformFile(rtc::PlatformFile handle) override; |
| 75 | int StopDebugRecording() override; |
| 76 | |
| 77 | // Capture-side exclusive methods possibly running APM in a |
| 78 | // multi-threaded manner. Acquire the capture lock. |
kjellander@webrtc.org | 14665ff | 2015-03-04 12:58:35 +0000 | [diff] [blame] | 79 | int ProcessStream(AudioFrame* frame) override; |
| 80 | int ProcessStream(const float* const* src, |
Peter Kasting | dce40cf | 2015-08-24 14:52:23 -0700 | [diff] [blame] | 81 | size_t samples_per_channel, |
kjellander@webrtc.org | 14665ff | 2015-03-04 12:58:35 +0000 | [diff] [blame] | 82 | int input_sample_rate_hz, |
| 83 | ChannelLayout input_layout, |
| 84 | int output_sample_rate_hz, |
| 85 | ChannelLayout output_layout, |
| 86 | float* const* dest) override; |
Michael Graczyk | 86c6d33 | 2015-07-23 11:41:39 -0700 | [diff] [blame] | 87 | int ProcessStream(const float* const* src, |
| 88 | const StreamConfig& input_config, |
| 89 | const StreamConfig& output_config, |
| 90 | float* const* dest) override; |
peah | df3efa8 | 2015-11-28 12:35:15 -0800 | [diff] [blame] | 91 | void set_output_will_be_muted(bool muted) override; |
| 92 | int set_stream_delay_ms(int delay) override; |
| 93 | void set_delay_offset_ms(int offset) override; |
| 94 | int delay_offset_ms() const override; |
| 95 | void set_stream_key_pressed(bool key_pressed) override; |
| 96 | |
| 97 | // Render-side exclusive methods possibly running APM in a |
| 98 | // multi-threaded manner. Acquire the render lock. |
kjellander@webrtc.org | 14665ff | 2015-03-04 12:58:35 +0000 | [diff] [blame] | 99 | int AnalyzeReverseStream(AudioFrame* frame) override; |
ekmeyerson | 60d9b33 | 2015-08-14 10:35:55 -0700 | [diff] [blame] | 100 | int ProcessReverseStream(AudioFrame* frame) override; |
kjellander@webrtc.org | 14665ff | 2015-03-04 12:58:35 +0000 | [diff] [blame] | 101 | int AnalyzeReverseStream(const float* const* data, |
Peter Kasting | dce40cf | 2015-08-24 14:52:23 -0700 | [diff] [blame] | 102 | size_t samples_per_channel, |
kjellander@webrtc.org | 14665ff | 2015-03-04 12:58:35 +0000 | [diff] [blame] | 103 | int sample_rate_hz, |
| 104 | ChannelLayout layout) override; |
ekmeyerson | 60d9b33 | 2015-08-14 10:35:55 -0700 | [diff] [blame] | 105 | int ProcessReverseStream(const float* const* src, |
| 106 | const StreamConfig& reverse_input_config, |
| 107 | const StreamConfig& reverse_output_config, |
| 108 | float* const* dest) override; |
peah | df3efa8 | 2015-11-28 12:35:15 -0800 | [diff] [blame] | 109 | |
| 110 | // Methods only accessed from APM submodules or |
| 111 | // from AudioProcessing tests in a single-threaded manner. |
| 112 | // Hence there is no need for locks in these. |
| 113 | int proc_sample_rate_hz() const override; |
| 114 | int proc_split_sample_rate_hz() const override; |
| 115 | int num_input_channels() const override; |
| 116 | int num_output_channels() const override; |
| 117 | int num_reverse_channels() const override; |
kjellander@webrtc.org | 14665ff | 2015-03-04 12:58:35 +0000 | [diff] [blame] | 118 | int stream_delay_ms() const override; |
peah | df3efa8 | 2015-11-28 12:35:15 -0800 | [diff] [blame] | 119 | bool was_stream_delay_set() const override |
| 120 | EXCLUSIVE_LOCKS_REQUIRED(crit_capture_); |
| 121 | |
| 122 | // Methods returning pointers to APM submodules. |
| 123 | // No locks are aquired in those, as those locks |
| 124 | // would offer no protection (the submodules are |
| 125 | // created only once in a single-treaded manner |
| 126 | // during APM creation). |
kjellander@webrtc.org | 14665ff | 2015-03-04 12:58:35 +0000 | [diff] [blame] | 127 | EchoCancellation* echo_cancellation() const override; |
| 128 | EchoControlMobile* echo_control_mobile() const override; |
| 129 | GainControl* gain_control() const override; |
| 130 | HighPassFilter* high_pass_filter() const override; |
| 131 | LevelEstimator* level_estimator() const override; |
| 132 | NoiseSuppression* noise_suppression() const override; |
| 133 | VoiceDetection* voice_detection() const override; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 134 | |
andrew@webrtc.org | 60730cf | 2014-01-07 17:45:09 +0000 | [diff] [blame] | 135 | protected: |
andrew@webrtc.org | a8b9737 | 2014-03-10 22:26:12 +0000 | [diff] [blame] | 136 | // Overridden in a mock. |
peah | df3efa8 | 2015-11-28 12:35:15 -0800 | [diff] [blame] | 137 | virtual int InitializeLocked() |
| 138 | EXCLUSIVE_LOCKS_REQUIRED(crit_render_, crit_capture_); |
andrew@webrtc.org | 60730cf | 2014-01-07 17:45:09 +0000 | [diff] [blame] | 139 | |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 140 | private: |
peah | df3efa8 | 2015-11-28 12:35:15 -0800 | [diff] [blame] | 141 | struct ApmPublicSubmodules; |
| 142 | struct ApmPrivateSubmodules; |
| 143 | |
| 144 | #ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP |
| 145 | // State for the debug dump. |
| 146 | struct ApmDebugDumpThreadState { |
| 147 | ApmDebugDumpThreadState() : event_msg(new audioproc::Event()) {} |
| 148 | rtc::scoped_ptr<audioproc::Event> event_msg; // Protobuf message. |
| 149 | std::string event_str; // Memory for protobuf serialization. |
| 150 | |
| 151 | // Serialized string of last saved APM configuration. |
| 152 | std::string last_serialized_config; |
| 153 | }; |
| 154 | |
| 155 | struct ApmDebugDumpState { |
| 156 | ApmDebugDumpState() : debug_file(FileWrapper::Create()) {} |
| 157 | rtc::scoped_ptr<FileWrapper> debug_file; |
| 158 | ApmDebugDumpThreadState render; |
| 159 | ApmDebugDumpThreadState capture; |
| 160 | }; |
| 161 | #endif |
| 162 | |
| 163 | // Method for modifying the formats struct that are called from both |
| 164 | // the render and capture threads. The check for whether modifications |
| 165 | // are needed is done while holding the render lock only, thereby avoiding |
| 166 | // that the capture thread blocks the render thread. |
| 167 | // The struct is modified in a single-threaded manner by holding both the |
| 168 | // render and capture locks. |
| 169 | int MaybeInitialize(const ProcessingConfig& config) |
| 170 | EXCLUSIVE_LOCKS_REQUIRED(crit_render_); |
| 171 | |
| 172 | int MaybeInitializeRender(const ProcessingConfig& processing_config) |
| 173 | EXCLUSIVE_LOCKS_REQUIRED(crit_render_); |
| 174 | |
| 175 | int MaybeInitializeCapture(const ProcessingConfig& processing_config) |
| 176 | EXCLUSIVE_LOCKS_REQUIRED(crit_render_); |
| 177 | |
| 178 | // Method for checking for the need of conversion. Accesses the formats |
| 179 | // structs in a read manner but the requirement for the render lock to be held |
| 180 | // was added as it currently anyway is always called in that manner. |
| 181 | bool rev_conversion_needed() const EXCLUSIVE_LOCKS_REQUIRED(crit_render_); |
| 182 | bool render_check_rev_conversion_needed() const |
| 183 | EXCLUSIVE_LOCKS_REQUIRED(crit_render_); |
| 184 | |
| 185 | // Methods requiring APM running in a single-threaded manner. |
| 186 | // Are called with both the render and capture locks already |
| 187 | // acquired. |
| 188 | void InitializeExperimentalAgc() |
| 189 | EXCLUSIVE_LOCKS_REQUIRED(crit_render_, crit_capture_); |
| 190 | void InitializeTransient() |
| 191 | EXCLUSIVE_LOCKS_REQUIRED(crit_render_, crit_capture_); |
| 192 | void InitializeBeamformer() |
| 193 | EXCLUSIVE_LOCKS_REQUIRED(crit_render_, crit_capture_); |
| 194 | void InitializeIntelligibility() |
| 195 | EXCLUSIVE_LOCKS_REQUIRED(crit_render_, crit_capture_); |
Michael Graczyk | 86c6d33 | 2015-07-23 11:41:39 -0700 | [diff] [blame] | 196 | int InitializeLocked(const ProcessingConfig& config) |
peah | df3efa8 | 2015-11-28 12:35:15 -0800 | [diff] [blame] | 197 | EXCLUSIVE_LOCKS_REQUIRED(crit_render_, crit_capture_); |
| 198 | |
| 199 | // Capture-side exclusive methods possibly running APM in a multi-threaded |
| 200 | // manner that are called with the render lock already acquired. |
| 201 | int ProcessStreamLocked() EXCLUSIVE_LOCKS_REQUIRED(crit_capture_); |
| 202 | bool output_copy_needed(bool is_data_processed) const |
| 203 | EXCLUSIVE_LOCKS_REQUIRED(crit_capture_); |
| 204 | bool is_data_processed() const EXCLUSIVE_LOCKS_REQUIRED(crit_capture_); |
| 205 | bool synthesis_needed(bool is_data_processed) const |
| 206 | EXCLUSIVE_LOCKS_REQUIRED(crit_capture_); |
| 207 | bool analysis_needed(bool is_data_processed) const |
| 208 | EXCLUSIVE_LOCKS_REQUIRED(crit_capture_); |
| 209 | void MaybeUpdateHistograms() EXCLUSIVE_LOCKS_REQUIRED(crit_capture_); |
| 210 | |
| 211 | // Render-side exclusive methods possibly running APM in a multi-threaded |
| 212 | // manner that are called with the render lock already acquired. |
ekmeyerson | 60d9b33 | 2015-08-14 10:35:55 -0700 | [diff] [blame] | 213 | // TODO(ekm): Remove once all clients updated to new interface. |
peah | df3efa8 | 2015-11-28 12:35:15 -0800 | [diff] [blame] | 214 | int AnalyzeReverseStreamLocked(const float* const* src, |
| 215 | const StreamConfig& input_config, |
| 216 | const StreamConfig& output_config) |
| 217 | EXCLUSIVE_LOCKS_REQUIRED(crit_render_); |
| 218 | bool is_rev_processed() const EXCLUSIVE_LOCKS_REQUIRED(crit_render_); |
| 219 | int ProcessReverseStreamLocked() EXCLUSIVE_LOCKS_REQUIRED(crit_render_); |
andrew@webrtc.org | 17e4064 | 2014-03-04 20:58:13 +0000 | [diff] [blame] | 220 | |
peah | df3efa8 | 2015-11-28 12:35:15 -0800 | [diff] [blame] | 221 | // Debug dump methods that are internal and called without locks. |
| 222 | // TODO(peah): Make thread safe. |
andrew@webrtc.org | 7bf2646 | 2011-12-03 00:03:31 +0000 | [diff] [blame] | 223 | #ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP |
| 224 | // TODO(andrew): make this more graceful. Ideally we would split this stuff |
| 225 | // out into a separate class with an "enabled" and "disabled" implementation. |
peah | df3efa8 | 2015-11-28 12:35:15 -0800 | [diff] [blame] | 226 | static int WriteMessageToDebugFile(FileWrapper* debug_file, |
| 227 | rtc::CriticalSection* crit_debug, |
| 228 | ApmDebugDumpThreadState* debug_state); |
| 229 | int WriteInitMessage() EXCLUSIVE_LOCKS_REQUIRED(crit_render_, crit_capture_); |
Minyue | 13b96ba | 2015-10-03 00:39:14 +0200 | [diff] [blame] | 230 | |
| 231 | // Writes Config message. If not |forced|, only writes the current config if |
| 232 | // it is different from the last saved one; if |forced|, writes the config |
| 233 | // regardless of the last saved. |
peah | df3efa8 | 2015-11-28 12:35:15 -0800 | [diff] [blame] | 234 | int WriteConfigMessage(bool forced) EXCLUSIVE_LOCKS_REQUIRED(crit_capture_) |
| 235 | EXCLUSIVE_LOCKS_REQUIRED(crit_capture_); |
Minyue | 13b96ba | 2015-10-03 00:39:14 +0200 | [diff] [blame] | 236 | |
peah | df3efa8 | 2015-11-28 12:35:15 -0800 | [diff] [blame] | 237 | // Critical section. |
| 238 | mutable rtc::CriticalSection crit_debug_; |
Minyue | 13b96ba | 2015-10-03 00:39:14 +0200 | [diff] [blame] | 239 | |
peah | df3efa8 | 2015-11-28 12:35:15 -0800 | [diff] [blame] | 240 | // Debug dump state. |
| 241 | ApmDebugDumpState debug_dump_; |
andrew@webrtc.org | 7bf2646 | 2011-12-03 00:03:31 +0000 | [diff] [blame] | 242 | #endif |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 243 | |
peah | df3efa8 | 2015-11-28 12:35:15 -0800 | [diff] [blame] | 244 | // Critical sections. |
| 245 | mutable rtc::CriticalSection crit_render_ ACQUIRED_BEFORE(crit_capture_); |
| 246 | mutable rtc::CriticalSection crit_capture_; |
| 247 | |
| 248 | // Structs containing the pointers to the submodules. |
| 249 | rtc::scoped_ptr<ApmPublicSubmodules> public_submodules_; |
| 250 | rtc::scoped_ptr<ApmPrivateSubmodules> private_submodules_ |
| 251 | GUARDED_BY(crit_capture_); |
| 252 | |
peah | 192164e | 2015-11-17 02:16:45 -0800 | [diff] [blame] | 253 | // State that is written to while holding both the render and capture locks |
peah | df3efa8 | 2015-11-28 12:35:15 -0800 | [diff] [blame] | 254 | // but can be read without any lock being held. |
| 255 | // As this is only accessed internally of APM, and all internal methods in APM |
| 256 | // either are holding the render or capture locks, this construct is safe as |
| 257 | // it is not possible to read the variables while writing them. |
| 258 | struct ApmFormatState { |
| 259 | ApmFormatState() |
peah | 192164e | 2015-11-17 02:16:45 -0800 | [diff] [blame] | 260 | : // Format of processing streams at input/output call sites. |
peah | df3efa8 | 2015-11-28 12:35:15 -0800 | [diff] [blame] | 261 | api_format({{{kSampleRate16kHz, 1, false}, |
| 262 | {kSampleRate16kHz, 1, false}, |
| 263 | {kSampleRate16kHz, 1, false}, |
| 264 | {kSampleRate16kHz, 1, false}}}), |
| 265 | rev_proc_format(kSampleRate16kHz, 1) {} |
| 266 | ProcessingConfig api_format; |
| 267 | StreamConfig rev_proc_format; |
| 268 | } formats_; |
Michael Graczyk | 86c6d33 | 2015-07-23 11:41:39 -0700 | [diff] [blame] | 269 | |
peah | df3efa8 | 2015-11-28 12:35:15 -0800 | [diff] [blame] | 270 | // APM constants. |
| 271 | const struct ApmConstants { |
| 272 | ApmConstants(int agc_startup_min_volume, |
| 273 | const std::vector<Point> array_geometry, |
| 274 | SphericalPointf target_direction, |
| 275 | bool use_new_agc, |
| 276 | bool intelligibility_enabled, |
| 277 | bool beamformer_enabled) |
| 278 | : // Format of processing streams at input/output call sites. |
| 279 | agc_startup_min_volume(agc_startup_min_volume), |
| 280 | array_geometry(array_geometry), |
| 281 | target_direction(target_direction), |
| 282 | use_new_agc(use_new_agc), |
| 283 | intelligibility_enabled(intelligibility_enabled), |
| 284 | beamformer_enabled(beamformer_enabled) {} |
| 285 | int agc_startup_min_volume; |
| 286 | std::vector<Point> array_geometry; |
| 287 | SphericalPointf target_direction; |
| 288 | bool use_new_agc; |
| 289 | bool intelligibility_enabled; |
| 290 | bool beamformer_enabled; |
| 291 | } constants_; |
andrew@webrtc.org | ddbb8a2 | 2014-04-22 21:00:04 +0000 | [diff] [blame] | 292 | |
peah | df3efa8 | 2015-11-28 12:35:15 -0800 | [diff] [blame] | 293 | struct ApmCaptureState { |
| 294 | ApmCaptureState(bool transient_suppressor_enabled) |
| 295 | : aec_system_delay_jumps(-1), |
| 296 | delay_offset_ms(0), |
| 297 | was_stream_delay_set(false), |
| 298 | last_stream_delay_ms(0), |
| 299 | last_aec_system_delay_ms(0), |
| 300 | stream_delay_jumps(-1), |
| 301 | output_will_be_muted(false), |
| 302 | key_pressed(false), |
| 303 | transient_suppressor_enabled(transient_suppressor_enabled), |
| 304 | fwd_proc_format(kSampleRate16kHz), |
| 305 | split_rate(kSampleRate16kHz) {} |
| 306 | int aec_system_delay_jumps; |
| 307 | int delay_offset_ms; |
| 308 | bool was_stream_delay_set; |
| 309 | int last_stream_delay_ms; |
| 310 | int last_aec_system_delay_ms; |
| 311 | int stream_delay_jumps; |
| 312 | bool output_will_be_muted; |
| 313 | bool key_pressed; |
| 314 | bool transient_suppressor_enabled; |
| 315 | rtc::scoped_ptr<AudioBuffer> capture_audio; |
| 316 | // Only the rate and samples fields of fwd_proc_format_ are used because the |
| 317 | // forward processing number of channels is mutable and is tracked by the |
| 318 | // capture_audio_. |
| 319 | StreamConfig fwd_proc_format; |
| 320 | int split_rate; |
| 321 | } capture_ GUARDED_BY(crit_capture_); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 322 | |
peah | df3efa8 | 2015-11-28 12:35:15 -0800 | [diff] [blame] | 323 | struct ApmCaptureNonLockedState { |
| 324 | ApmCaptureNonLockedState() |
| 325 | : fwd_proc_format(kSampleRate16kHz), |
| 326 | split_rate(kSampleRate16kHz), |
| 327 | stream_delay_ms(0) {} |
| 328 | // Only the rate and samples fields of fwd_proc_format_ are used because the |
| 329 | // forward processing number of channels is mutable and is tracked by the |
| 330 | // capture_audio_. |
| 331 | StreamConfig fwd_proc_format; |
| 332 | int split_rate; |
| 333 | int stream_delay_ms; |
| 334 | } capture_nonlocked_; |
andrew@webrtc.org | 75dd288 | 2014-02-11 20:52:30 +0000 | [diff] [blame] | 335 | |
peah | df3efa8 | 2015-11-28 12:35:15 -0800 | [diff] [blame] | 336 | struct ApmRenderState { |
| 337 | rtc::scoped_ptr<AudioConverter> render_converter; |
| 338 | rtc::scoped_ptr<AudioBuffer> render_audio; |
| 339 | } render_ GUARDED_BY(crit_render_); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 340 | }; |
andrew@webrtc.org | ddbb8a2 | 2014-04-22 21:00:04 +0000 | [diff] [blame] | 341 | |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 342 | } // namespace webrtc |
| 343 | |
pbos@webrtc.org | 788acd1 | 2014-12-15 09:41:24 +0000 | [diff] [blame] | 344 | #endif // WEBRTC_MODULES_AUDIO_PROCESSING_AUDIO_PROCESSING_IMPL_H_ |