summaryrefslogtreecommitdiff
path: root/servers/audio/effects
diff options
context:
space:
mode:
Diffstat (limited to 'servers/audio/effects')
-rw-r--r--servers/audio/effects/audio_effect_capture.cpp8
-rw-r--r--servers/audio/effects/audio_effect_capture.h4
-rw-r--r--servers/audio/effects/audio_effect_distortion.cpp3
3 files changed, 8 insertions, 7 deletions
diff --git a/servers/audio/effects/audio_effect_capture.cpp b/servers/audio/effects/audio_effect_capture.cpp
index f37938eec8..37e4122e50 100644
--- a/servers/audio/effects/audio_effect_capture.cpp
+++ b/servers/audio/effects/audio_effect_capture.cpp
@@ -106,7 +106,7 @@ int AudioEffectCapture::get_frames_available() const {
}
int64_t AudioEffectCapture::get_discarded_frames() const {
- return discarded_frames;
+ return discarded_frames.get();
}
int AudioEffectCapture::get_buffer_length_frames() const {
@@ -115,7 +115,7 @@ int AudioEffectCapture::get_buffer_length_frames() const {
}
int64_t AudioEffectCapture::get_pushed_frames() const {
- return pushed_frames;
+ return pushed_frames.get();
}
void AudioEffectCaptureInstance::process(const AudioFrame *p_src_frames, AudioFrame *p_dst_frames, int p_frame_count) {
@@ -129,9 +129,9 @@ void AudioEffectCaptureInstance::process(const AudioFrame *p_src_frames, AudioFr
// Add incoming audio frames to the IO ring buffer
int32_t ret = buffer.write(p_src_frames, p_frame_count);
ERR_FAIL_COND_MSG(ret != p_frame_count, "Failed to add data to effect capture ring buffer despite sufficient space.");
- atomic_add(&base->pushed_frames, p_frame_count);
+ base->pushed_frames.add(p_frame_count);
} else {
- atomic_add(&base->discarded_frames, p_frame_count);
+ base->discarded_frames.add(p_frame_count);
}
}
diff --git a/servers/audio/effects/audio_effect_capture.h b/servers/audio/effects/audio_effect_capture.h
index b154be85de..81d4ed6b0f 100644
--- a/servers/audio/effects/audio_effect_capture.h
+++ b/servers/audio/effects/audio_effect_capture.h
@@ -55,8 +55,8 @@ class AudioEffectCapture : public AudioEffect {
friend class AudioEffectCaptureInstance;
RingBuffer<AudioFrame> buffer;
- uint64_t discarded_frames = 0;
- uint64_t pushed_frames = 0;
+ SafeNumeric<uint64_t> discarded_frames;
+ SafeNumeric<uint64_t> pushed_frames;
float buffer_length_seconds = 0.1f;
bool buffer_initialized = false;
diff --git a/servers/audio/effects/audio_effect_distortion.cpp b/servers/audio/effects/audio_effect_distortion.cpp
index b79434e7c2..06d51776a3 100644
--- a/servers/audio/effects/audio_effect_distortion.cpp
+++ b/servers/audio/effects/audio_effect_distortion.cpp
@@ -58,7 +58,8 @@ void AudioEffectDistortionInstance::process(const AudioFrame *p_src_frames, Audi
switch (base->mode) {
case AudioEffectDistortion::MODE_CLIP: {
- a = powf(a, 1.0001 - drive_f);
+ float a_sign = a < 0 ? -1.0f : 1.0f;
+ a = powf(abs(a), 1.0001 - drive_f) * a_sign;
if (a > 1.0) {
a = 1.0;
} else if (a < (-1.0)) {