GB, GBA Audio: More efficient sample writing

This commit is contained in:
Vicki Pfau 2024-04-22 04:19:50 -07:00
parent d5e49a5981
commit 3f54bcbc87
2 changed files with 10 additions and 18 deletions

View File

@ -823,15 +823,11 @@ static void _sample(struct mTiming* timing, void* user, uint32_t cyclesLate) {
mCoreSyncLockAudio(audio->p->sync); mCoreSyncLockAudio(audio->p->sync);
unsigned produced; unsigned produced;
int i; mAudioBufferWrite(&audio->buffer, (int16_t*) audio->currentSamples, GB_MAX_SAMPLES);
for (i = 0; i < GB_MAX_SAMPLES; ++i) { if (audio->p->stream && audio->p->stream->postAudioFrame) {
int16_t sample[2] = { int i;
audio->currentSamples[i].left, for (i = 0; i < GB_MAX_SAMPLES; ++i) {
audio->currentSamples[i].right audio->p->stream->postAudioFrame(audio->p->stream, audio->currentSamples[i].left,audio->currentSamples[i].right);
};
mAudioBufferWrite(&audio->buffer, sample, 1);
if (audio->p->stream && audio->p->stream->postAudioFrame) {
audio->p->stream->postAudioFrame(audio->p->stream, sample[0], sample[1]);
} }
} }

View File

@ -393,15 +393,11 @@ static void _sample(struct mTiming* timing, void* user, uint32_t cyclesLate) {
mCoreSyncLockAudio(audio->p->sync); mCoreSyncLockAudio(audio->p->sync);
unsigned produced; unsigned produced;
int i; mAudioBufferWrite(&audio->psg.buffer, (int16_t*) audio->currentSamples, samples);
for (i = 0; i < samples; ++i) { if (audio->p->stream && audio->p->stream->postAudioFrame) {
int16_t sample[2] = { int i;
audio->currentSamples[i].left, for (i = 0; i < samples; ++i) {
audio->currentSamples[i].right audio->p->stream->postAudioFrame(audio->p->stream, audio->currentSamples[i].left,audio->currentSamples[i].right);
};
mAudioBufferWrite(&audio->psg.buffer, sample, 1);
if (audio->p->stream && audio->p->stream->postAudioFrame) {
audio->p->stream->postAudioFrame(audio->p->stream, sample[0], sample[1]);
} }
} }
produced = mAudioBufferAvailable(&audio->psg.buffer); produced = mAudioBufferAvailable(&audio->psg.buffer);