mirror of https://github.com/mgba-emu/mgba.git
Util: Early exist mAudioBufferRead if the buffer is full
This commit is contained in:
parent
2bce03023b
commit
55add8a2c6
|
@ -52,6 +52,9 @@ size_t mAudioBufferRead(struct mAudioBuffer* buffer, int16_t* samples, size_t co
|
||||||
size_t mAudioBufferWrite(struct mAudioBuffer* buffer, const int16_t* samples, size_t count) {
|
size_t mAudioBufferWrite(struct mAudioBuffer* buffer, const int16_t* samples, size_t count) {
|
||||||
size_t free = mCircleBufferCapacity(&buffer->data) - mCircleBufferSize(&buffer->data);
|
size_t free = mCircleBufferCapacity(&buffer->data) - mCircleBufferSize(&buffer->data);
|
||||||
if (count * buffer->channels * sizeof(int16_t) > free) {
|
if (count * buffer->channels * sizeof(int16_t) > free) {
|
||||||
|
if (!free) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
count = free / (buffer->channels * sizeof(int16_t));
|
count = free / (buffer->channels * sizeof(int16_t));
|
||||||
}
|
}
|
||||||
return mCircleBufferWrite(&buffer->data, samples, count * buffer->channels * sizeof(int16_t)) /
|
return mCircleBufferWrite(&buffer->data, samples, count * buffer->channels * sizeof(int16_t)) /
|
||||||
|
|
Loading…
Reference in New Issue