Core: Rename GBAStereoSample to mStereoSample

This commit is contained in:
Vicki Pfau 2022-06-15 18:39:38 -07:00
parent a0613e27ab
commit 33b3d33da2
7 changed files with 20 additions and 19 deletions

View File

@ -194,6 +194,11 @@ struct mAVStream {
void (*postAudioBuffer)(struct mAVStream*, struct blip_t* left, struct blip_t* right); void (*postAudioBuffer)(struct mAVStream*, struct blip_t* left, struct blip_t* right);
}; };
struct mStereoSample {
int16_t left;
int16_t right;
};
struct mKeyCallback { struct mKeyCallback {
uint16_t (*readKeys)(struct mKeyCallback*); uint16_t (*readKeys)(struct mKeyCallback*);
bool requireOpposingDirections; bool requireOpposingDirections;

View File

@ -11,6 +11,7 @@
CXX_GUARD_START CXX_GUARD_START
#include <mgba/core/cpu.h> #include <mgba/core/cpu.h>
#include <mgba/core/interface.h>
#include <mgba/core/log.h> #include <mgba/core/log.h>
#include <mgba/internal/gb/audio.h> #include <mgba/internal/gb/audio.h>
#include <mgba-util/circle-buffer.h> #include <mgba-util/circle-buffer.h>
@ -94,11 +95,6 @@ struct GBAAudio {
struct mTimingEvent sampleEvent; struct mTimingEvent sampleEvent;
}; };
struct GBAStereoSample {
int16_t left;
int16_t right;
};
struct GBAMP2kADSR { struct GBAMP2kADSR {
uint8_t attack; uint8_t attack;
uint8_t decay; uint8_t decay;
@ -278,7 +274,7 @@ struct GBAAudioMixer {
double tempo; double tempo;
double frame; double frame;
struct GBAStereoSample last; struct mStereoSample last;
}; };
void GBAAudioInit(struct GBAAudio* audio, size_t samples); void GBAAudioInit(struct GBAAudio* audio, size_t samples);

View File

@ -125,7 +125,7 @@ static void _stepSample(struct GBAAudioMixer* mixer, struct GBAMP2kTrack* track)
for (nSample = 0; nSample < updates; ++nSample) { for (nSample = 0; nSample < updates; ++nSample) {
int8_t sample = memory->load8(cpu, sampleBase + sampleI, 0); int8_t sample = memory->load8(cpu, sampleBase + sampleI, 0);
struct GBAStereoSample stereo = { struct mStereoSample stereo = {
(sample * track->channel->leftVolume * track->channel->envelopeV) >> 9, (sample * track->channel->leftVolume * track->channel->envelopeV) >> 9,
(sample * track->channel->rightVolume * track->channel->envelopeV) >> 9 (sample * track->channel->rightVolume * track->channel->envelopeV) >> 9
}; };
@ -277,7 +277,7 @@ void _mp2kStep(struct GBAAudioMixer* mixer) {
uint32_t interval = mixer->p->sampleInterval / OVERSAMPLE; uint32_t interval = mixer->p->sampleInterval / OVERSAMPLE;
int i; int i;
for (i = 0; i < OVERSAMPLE; ++i) { for (i = 0; i < OVERSAMPLE; ++i) {
struct GBAStereoSample sample = {0}; struct mStereoSample sample = {0};
size_t track; size_t track;
for (track = 0; track < MP2K_MAX_SOUND_CHANNELS; ++track) { for (track = 0; track < MP2K_MAX_SOUND_CHANNELS; ++track) {
if (!mixer->activeTracks[track].channel->status) { if (!mixer->activeTracks[track].channel->status) {

View File

@ -88,7 +88,7 @@ static vita2d_texture* backdrop = 0;
#define PSP2_AUDIO_BUFFER_SIZE (PSP2_SAMPLES * 16) #define PSP2_AUDIO_BUFFER_SIZE (PSP2_SAMPLES * 16)
static struct mPSP2AudioContext { static struct mPSP2AudioContext {
struct GBAStereoSample buffer[PSP2_AUDIO_BUFFER_SIZE]; struct mStereoSample buffer[PSP2_AUDIO_BUFFER_SIZE];
size_t writeOffset; size_t writeOffset;
size_t readOffset; size_t readOffset;
size_t samples; size_t samples;
@ -255,7 +255,7 @@ static void _postAudioBuffer(struct mAVStream* stream, blip_t* left, blip_t* rig
} }
ConditionWait(&audioContext.cond, &audioContext.mutex); ConditionWait(&audioContext.cond, &audioContext.mutex);
} }
struct GBAStereoSample* samples = &audioContext.buffer[audioContext.writeOffset]; struct mStereoSample* samples = &audioContext.buffer[audioContext.writeOffset];
blip_read_samples(left, &samples[0].left, PSP2_SAMPLES, true); blip_read_samples(left, &samples[0].left, PSP2_SAMPLES, true);
blip_read_samples(right, &samples[0].right, PSP2_SAMPLES, true); blip_read_samples(right, &samples[0].right, PSP2_SAMPLES, true);
audioContext.samples += PSP2_SAMPLES; audioContext.samples += PSP2_SAMPLES;

View File

@ -45,17 +45,17 @@ qint64 AudioDevice::readData(char* data, qint64 maxSize) {
return 0; return 0;
} }
maxSize /= sizeof(GBAStereoSample); maxSize /= sizeof(mStereoSample);
mCoreSyncLockAudio(&m_context->impl->sync); mCoreSyncLockAudio(&m_context->impl->sync);
int available = std::min<qint64>({ int available = std::min<qint64>({
blip_samples_avail(m_context->core->getAudioChannel(m_context->core, 0)), blip_samples_avail(m_context->core->getAudioChannel(m_context->core, 0)),
maxSize, maxSize,
std::numeric_limits<int>::max() std::numeric_limits<int>::max()
}); });
blip_read_samples(m_context->core->getAudioChannel(m_context->core, 0), &reinterpret_cast<GBAStereoSample*>(data)->left, available, true); blip_read_samples(m_context->core->getAudioChannel(m_context->core, 0), &reinterpret_cast<mStereoSample*>(data)->left, available, true);
blip_read_samples(m_context->core->getAudioChannel(m_context->core, 1), &reinterpret_cast<GBAStereoSample*>(data)->right, available, true); blip_read_samples(m_context->core->getAudioChannel(m_context->core, 1), &reinterpret_cast<mStereoSample*>(data)->right, available, true);
mCoreSyncConsumeAudio(&m_context->impl->sync); mCoreSyncConsumeAudio(&m_context->impl->sync);
return available * sizeof(GBAStereoSample); return available * sizeof(mStereoSample);
} }
qint64 AudioDevice::writeData(const char*, qint64) { qint64 AudioDevice::writeData(const char*, qint64) {

View File

@ -115,7 +115,7 @@ static float gyroZ = 0;
static float tiltX = 0; static float tiltX = 0;
static float tiltY = 0; static float tiltY = 0;
static struct GBAStereoSample audioBuffer[N_BUFFERS][BUFFER_SIZE / 4] __attribute__((__aligned__(0x1000))); static struct mStereoSample audioBuffer[N_BUFFERS][BUFFER_SIZE / 4] __attribute__((__aligned__(0x1000)));
static enum ScreenMode { static enum ScreenMode {
SM_PA, SM_PA,
@ -584,7 +584,7 @@ static void _postAudioBuffer(struct mAVStream* stream, blip_t* left, blip_t* rig
blip_clear(right); blip_clear(right);
return; return;
} }
struct GBAStereoSample* samples = audioBuffer[audioBufferActive]; struct mStereoSample* samples = audioBuffer[audioBufferActive];
blip_read_samples(left, &samples[0].left, SAMPLES, true); blip_read_samples(left, &samples[0].left, SAMPLES, true);
blip_read_samples(right, &samples[0].right, SAMPLES, true); blip_read_samples(right, &samples[0].right, SAMPLES, true);
audoutAppendAudioOutBuffer(&audoutBuffer[audioBufferActive]); audoutAppendAudioOutBuffer(&audoutBuffer[audioBufferActive]);

View File

@ -141,7 +141,7 @@ static void* framebuffer[2] = { 0, 0 };
static int whichFb = 0; static int whichFb = 0;
static struct AudioBuffer { static struct AudioBuffer {
struct GBAStereoSample samples[SAMPLES] __attribute__((__aligned__(32))); struct mStereoSample samples[SAMPLES] __attribute__((__aligned__(32)));
volatile size_t size; volatile size_t size;
} audioBuffer[BUFFERS] = {0}; } audioBuffer[BUFFERS] = {0};
static volatile int currentAudioBuffer = 0; static volatile int currentAudioBuffer = 0;
@ -685,8 +685,8 @@ static void _audioDMA(void) {
if (buffer->size != SAMPLES) { if (buffer->size != SAMPLES) {
return; return;
} }
DCFlushRange(buffer->samples, SAMPLES * sizeof(struct GBAStereoSample)); DCFlushRange(buffer->samples, SAMPLES * sizeof(struct mStereoSample));
AUDIO_InitDMA((u32) buffer->samples, SAMPLES * sizeof(struct GBAStereoSample)); AUDIO_InitDMA((u32) buffer->samples, SAMPLES * sizeof(struct mStereoSample));
buffer->size = 0; buffer->size = 0;
currentAudioBuffer = (currentAudioBuffer + 1) % BUFFERS; currentAudioBuffer = (currentAudioBuffer + 1) % BUFFERS;
} }