Skip to content

Commit 8fab630

Browse files
committed
retro-core: Removed shared audio buffer
It wasn't used by all apps, wasteful.
1 parent 86075b6 commit 8fab630

File tree

6 files changed

+9
-7
lines changed

6 files changed

+9
-7
lines changed

retro-core/main/main.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#include "shared.h"
22

3-
rg_audio_sample_t audioBuffer[AUDIO_BUFFER_LENGTH];
43
rg_app_t *app;
54

65

retro-core/main/main_gbc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ void gbc_main(void)
267267
RG_PANIC("Emulator init failed!");
268268

269269
gnuboy_set_framebuffer(currentUpdate->data);
270-
gnuboy_set_soundbuffer((void *)audioBuffer, sizeof(audioBuffer) / 2);
270+
gnuboy_set_soundbuffer(malloc(AUDIO_BUFFER_LENGTH * 4), AUDIO_BUFFER_LENGTH);
271271

272272
// Load ROM
273273
if (rg_extension_match(app->romPath, "zip"))

retro-core/main/main_lynx.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ extern "C" void lynx_main(void)
210210
}
211211

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

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

267-
rg_audio_submit(audioBuffer, gAudioBufferPointer >> 1);
267+
rg_audio_submit((const rg_audio_frame_t *)gAudioBuffer, gAudioBufferPointer / 2);
268268

269269
// See if we need to skip a frame to keep up
270270
if (skipFrames == 0)

retro-core/main/main_pce.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,11 +135,12 @@ static void audioTask(void *arg)
135135
RG_LOGI("task started. numSamples=%d.", (int)numSamples);
136136
while (1)
137137
{
138+
rg_audio_sample_t samples[numSamples];
138139
// TODO: Clearly we need to add a better way to remain in sync with the main task...
139140
while (emulationPaused)
140141
rg_task_yield();
141-
psg_update((int16_t *)audioBuffer, numSamples, 0xFF);
142-
rg_audio_submit(audioBuffer, numSamples);
142+
psg_update((int16_t *)samples, numSamples, 0xFF);
143+
rg_audio_submit(samples, numSamples);
143144
}
144145
}
145146

retro-core/main/main_snes.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ static const char *SNES_BUTTONS[] = {
6868

6969
static rg_surface_t *updates[2];
7070
static rg_surface_t *currentUpdate;
71+
static rg_audio_sample_t *audioBuffer;
7172

7273
static bool apu_enabled = true;
7374
static bool lowpass_filter = false;
@@ -305,6 +306,8 @@ void snes_main(void)
305306
updates[0]->height = SNES_HEIGHT;
306307
currentUpdate = updates[0];
307308

309+
audioBuffer = (rg_audio_sample_t *)malloc(AUDIO_BUFFER_LENGTH * 4);
310+
308311
update_keymap(rg_settings_get_number(NS_APP, SETTING_KEYMAP, 0));
309312

310313
Settings.CyclesPercentage = 100;

retro-core/main/shared.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
#define AUDIO_SAMPLE_RATE (32000)
88
#define AUDIO_BUFFER_LENGTH (AUDIO_SAMPLE_RATE / 50 + 1)
99

10-
extern rg_audio_sample_t audioBuffer[AUDIO_BUFFER_LENGTH];
1110
extern rg_app_t *app;
1211

1312
extern uint8_t shared_memory_block_64K[0x10000];

0 commit comments

Comments
 (0)