Skip to content

Commit

Permalink
retro-core: Removed shared audio buffer
Browse files Browse the repository at this point in the history
It wasn't used by all apps, wasteful.
  • Loading branch information
ducalex committed Nov 29, 2024
1 parent 86075b6 commit e61ed3a
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 7 deletions.
1 change: 0 additions & 1 deletion retro-core/main/main.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#include "shared.h"

rg_audio_sample_t audioBuffer[AUDIO_BUFFER_LENGTH];
rg_app_t *app;


Expand Down
2 changes: 1 addition & 1 deletion retro-core/main/main_gbc.c
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ void gbc_main(void)
RG_PANIC("Emulator init failed!");

gnuboy_set_framebuffer(currentUpdate->data);
gnuboy_set_soundbuffer((void *)audioBuffer, sizeof(audioBuffer) / 2);
gnuboy_set_soundbuffer(malloc(AUDIO_BUFFER_LENGTH * 4), AUDIO_SAMPLE_RATE);

// Load ROM
if (rg_extension_match(app->romPath, "zip"))
Expand Down
4 changes: 2 additions & 2 deletions retro-core/main/main_lynx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ extern "C" void lynx_main(void)
}

gPrimaryFrameBuffer = (UBYTE*)currentUpdate->data;
gAudioBuffer = (SWORD*)&audioBuffer;
gAudioBuffer = (SWORD*)malloc(AUDIO_BUFFER_LENGTH * 4);
gAudioEnabled = 1;

if (app->bootFlags & RG_BOOT_RESUME)
Expand Down Expand Up @@ -264,7 +264,7 @@ extern "C" void lynx_main(void)
rg_system_set_tick_rate(AUDIO_SAMPLE_RATE / (gAudioBufferPointer / 2));
rg_system_tick(rg_system_timer() - startTime);

rg_audio_submit(audioBuffer, gAudioBufferPointer >> 1);
rg_audio_submit((const rg_audio_frame_t *)gAudioBuffer, gAudioBufferPointer / 2);

// See if we need to skip a frame to keep up
if (skipFrames == 0)
Expand Down
5 changes: 3 additions & 2 deletions retro-core/main/main_pce.c
Original file line number Diff line number Diff line change
Expand Up @@ -135,11 +135,12 @@ static void audioTask(void *arg)
RG_LOGI("task started. numSamples=%d.", (int)numSamples);
while (1)
{
rg_audio_sample_t samples[numSamples];
// TODO: Clearly we need to add a better way to remain in sync with the main task...
while (emulationPaused)
rg_task_yield();
psg_update((int16_t *)audioBuffer, numSamples, 0xFF);
rg_audio_submit(audioBuffer, numSamples);
psg_update((int16_t *)samples, numSamples, 0xFF);
rg_audio_submit(samples, numSamples);
}
}

Expand Down
3 changes: 3 additions & 0 deletions retro-core/main/main_snes.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ static const char *SNES_BUTTONS[] = {

static rg_surface_t *updates[2];
static rg_surface_t *currentUpdate;
static rg_audio_sample_t *audioBuffer;

static bool apu_enabled = true;
static bool lowpass_filter = false;
Expand Down Expand Up @@ -305,6 +306,8 @@ void snes_main(void)
updates[0]->height = SNES_HEIGHT;
currentUpdate = updates[0];

audioBuffer = (rg_audio_sample_t *)malloc(AUDIO_BUFFER_LENGTH * 4);

update_keymap(rg_settings_get_number(NS_APP, SETTING_KEYMAP, 0));

Settings.CyclesPercentage = 100;
Expand Down
1 change: 0 additions & 1 deletion retro-core/main/shared.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
#define AUDIO_SAMPLE_RATE (32000)
#define AUDIO_BUFFER_LENGTH (AUDIO_SAMPLE_RATE / 50 + 1)

extern rg_audio_sample_t audioBuffer[AUDIO_BUFFER_LENGTH];
extern rg_app_t *app;

extern uint8_t shared_memory_block_64K[0x10000];
Expand Down

0 comments on commit e61ed3a

Please sign in to comment.