andrewrk / andrewrk/libsoundio

ring_buffer asserts on overflow

Ouverte
#159 1 commentaire 2 réactions 0 personnes assignées Voir sur GitHub
Langage dominant
C
Étoiles
2.1k
Forks
254
Métriques de merge des PR
Aucune PR mergée en 30 j

Description

```
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.

Guide de contribution

Aucun guide de contribution indexé pour ce dépôt

Évaluation

Cette issue n'a pas encore été évaluée.

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.