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);
unsigned produced;
int i;
for (i = 0; i < GB_MAX_SAMPLES; ++i) {
int16_t sample[2] = {
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]);
mAudioBufferWrite(&audio->buffer, (int16_t*) audio->currentSamples, GB_MAX_SAMPLES);
if (audio->p->stream && audio->p->stream->postAudioFrame) {
int i;
for (i = 0; i < GB_MAX_SAMPLES; ++i) {
audio->p->stream->postAudioFrame(audio->p->stream, audio->currentSamples[i].left,audio->currentSamples[i].right);
}
}

View File

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