andrewrk / andrewrk/libsoundio

ring_buffer asserts on overflow

Aperta
#159 1 commento 2 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
C
Stelle
2.1k
Fork
254
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

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

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.