Core: Add functions to get native sample rates

This commit is contained in:
Vicki Pfau 2024-04-16 21:01:58 -07:00
parent 73a39dea65
commit 7b2edbd1bd
3 changed files with 13 additions and 0 deletions

View File

@ -78,6 +78,7 @@ struct mCore {
void (*getPixels)(struct mCore*, const void** buffer, size_t* stride);
void (*putPixels)(struct mCore*, const void* buffer, size_t stride);
unsigned (*audioSampleRate)(const struct mCore*);
struct blip_t* (*getAudioChannel)(struct mCore*, int ch);
void (*setAudioBufferSize)(struct mCore*, size_t samples);
size_t (*getAudioBufferSize)(struct mCore*);

View File

@ -445,6 +445,11 @@ static void _GBCoreSetAudioBufferSize(struct mCore* core, size_t samples) {
GBAudioResizeBuffer(&gb->audio, samples);
}
static unsigned _GBCoreAudioSampleRate(const struct mCore* core) {
UNUSED(core);
return 131072;
}
static size_t _GBCoreGetAudioBufferSize(struct mCore* core) {
struct GB* gb = core->board;
return gb->audio.samples;
@ -1302,6 +1307,7 @@ struct mCore* GBCoreCreate(void) {
core->setVideoGLTex = _GBCoreSetVideoGLTex;
core->getPixels = _GBCoreGetPixels;
core->putPixels = _GBCorePutPixels;
core->audioSampleRate = _GBCoreAudioSampleRate;
core->getAudioChannel = _GBCoreGetAudioChannel;
core->setAudioBufferSize = _GBCoreSetAudioBufferSize;
core->getAudioBufferSize = _GBCoreGetAudioBufferSize;

View File

@ -559,6 +559,11 @@ static void _GBACorePutPixels(struct mCore* core, const void* buffer, size_t str
gba->video.renderer->putPixels(gba->video.renderer, stride, buffer);
}
static unsigned _GBACoreAudioSampleRate(const struct mCore* core) {
UNUSED(core);
return 65536;
}
static struct blip_t* _GBACoreGetAudioChannel(struct mCore* core, int ch) {
struct GBA* gba = core->board;
switch (ch) {
@ -1515,6 +1520,7 @@ struct mCore* GBACoreCreate(void) {
core->setVideoGLTex = _GBACoreSetVideoGLTex;
core->getPixels = _GBACoreGetPixels;
core->putPixels = _GBACorePutPixels;
core->audioSampleRate = _GBACoreAudioSampleRate;
core->getAudioChannel = _GBACoreGetAudioChannel;
core->setAudioBufferSize = _GBACoreSetAudioBufferSize;
core->getAudioBufferSize = _GBACoreGetAudioBufferSize;