all repos — mgba @ e38a01f22178e3628949b748087877f81961522c

mGBA Game Boy Advance Emulator

GBA Audio: Make larger buffer sizes than 2048 actually work properly

Conflicts:
	src/gba/gba-audio.c
Jeffrey Pfau jeffrey@endrift.com
Sun, 21 Dec 2014 21:27:55 -0800
commit

e38a01f22178e3628949b748087877f81961522c

parent

cbcfffcba40cba6fcdab302e599920d6217adc00

2 files changed, 8 insertions(+), 8 deletions(-)

jump to
M CHANGESCHANGES

@@ -11,6 +11,7 @@ - Debugger: Negative PC-relative loads now properly subtract the offset

- Qt: Fix window focus issues - GBA Memory: Properly initialize 1 Mb flash, and add debug logging - Qt: Properly set default video recording settings + - GBA Audio: Make larger buffer sizes than 2048 actually work properly Misc: - Qt: Disable sync to video by default - GBA: Exit cleanly on FATAL if the port supports it
M src/gba/gba-audio.csrc/gba/gba-audio.c

@@ -91,17 +91,14 @@ CircleBufferDeinit(&audio->chB.fifo);

} void GBAAudioResizeBuffer(struct GBAAudio* audio, size_t samples) { - if (samples > GBA_AUDIO_SAMPLES) { - return; - } - GBASyncLockAudio(audio->p->sync); - int32_t buffer[GBA_AUDIO_SAMPLES]; + size_t oldCapacity = audio->left.capacity; + int32_t* buffer = malloc(oldCapacity); int32_t dummy; size_t read; size_t i; - read = CircleBufferDump(&audio->left, buffer, sizeof(buffer)); + read = CircleBufferDump(&audio->left, buffer, oldCapacity); CircleBufferDeinit(&audio->left); CircleBufferInit(&audio->left, samples * sizeof(int32_t)); for (i = 0; i * sizeof(int32_t) < read; ++i) {

@@ -111,7 +108,7 @@ CircleBufferWrite32(&audio->left, buffer[i]);

} } - read = CircleBufferDump(&audio->right, buffer, sizeof(buffer)); + read = CircleBufferDump(&audio->right, buffer, oldCapacity); CircleBufferDeinit(&audio->right); CircleBufferInit(&audio->right, samples * sizeof(int32_t)); for (i = 0; i * sizeof(int32_t) < read; ++i) {

@@ -120,6 +117,8 @@ CircleBufferRead32(&audio->right, &dummy);

CircleBufferWrite32(&audio->right, buffer[i]); } } + + free(buffer); GBASyncConsumeAudio(audio->p->sync); }

@@ -755,7 +754,7 @@ struct GBAThread* thread = GBAThreadGetContext();

if (thread && thread->stream) { thread->stream->postAudioFrame(thread->stream, sampleLeft, sampleRight); } - GBASyncProduceAudio(audio->p->sync, produced >= CircleBufferCapacity(&audio->left) / sizeof(int32_t) * 3); + GBASyncProduceAudio(audio->p->sync, produced >= CircleBufferCapacity(&audio->left)); } void GBAAudioSerialize(const struct GBAAudio* audio, struct GBASerializedState* state) {