Modernize atomics
- Based on C++11's `atomic` - Reworked `SafeRefCount` (based on the rewrite by @hpvb) - Replaced free atomic functions by the new `SafeNumeric<T>` - Replaced wrong cases of `volatile bool` by the new `SafeFlag` - Platform-specific implementations no longer needed Co-authored-by: Hein-Pieter van Braam-Stewart <hp@tmm.cx>
This commit is contained in:
parent
8870f43d74
commit
8e128726f0
58 changed files with 650 additions and 639 deletions
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue