andrewrk / andrewrk/libsoundio
ring_buffer asserts on overflow
- Vorherrschende Sprache
- C
- Sterne
- 2.1k
- Forks
- 254
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Beschreibung
```
int soundio_ring_buffer_fill_count(struct SoundIoRingBuffer *rb) {
// Whichever offset we load first might have a smaller value. So we load
// the read_offset first.
long read_offset = SOUNDIO_ATOMIC_LOAD(rb->read_offset);
long write_offset = SOUNDIO_ATOMIC_LOAD(rb->write_offset);
int count = write_offset - read_offset;
assert(count >= 0);
assert(count <= rb->capacity);
return count;
}
```
I guess that is by design but it is definitely not the expected behaviour. I would either expect the read pointer to follow the write pointer when it was full. This would require the ring buffer to know its element size which is probably a good idea anyway.
Beitragsleitfaden
Für dieses Repository ist kein Beitragsleitfaden indexiert
Bewertung
Dieses Issue wurde noch nicht bewertet.