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

Conflicts:
	src/gba/gba-audio.c
This commit is contained in:
Jeffrey Pfau 2014-12-21 21:27:55 -08:00
parent cbcfffcba4
commit e38a01f221
2 changed files with 8 additions and 8 deletions

View File

@ -11,6 +11,7 @@ Bugfixes:
- 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

View File

@ -91,17 +91,14 @@ void GBAAudioDeinit(struct GBAAudio* audio) {
}
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 @@ void GBAAudioResizeBuffer(struct GBAAudio* audio, size_t samples) {
}
}
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) {
@ -121,6 +118,8 @@ void GBAAudioResizeBuffer(struct GBAAudio* audio, size_t samples) {
}
}
free(buffer);
GBASyncConsumeAudio(audio->p->sync);
}
@ -755,7 +754,7 @@ static void _sample(struct GBAAudio* audio) {
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) {