all repos — mgba @ 6e727db553141811d10ec9e0478c8343d6dda2cb

mGBA Game Boy Advance Emulator

Set buffer size to 512 samples in the SDL/GL port
Jeffrey Pfau jeffrey@endrift.com
Mon, 21 Jul 2014 00:29:38 -0700
commit

6e727db553141811d10ec9e0478c8343d6dda2cb

parent

e5272203987c17d9de06662a840ff5fb7b383689

M src/gba/gba-audio.csrc/gba/gba-audio.c

@@ -6,7 +6,7 @@ #include "gba-serialize.h"

#include "gba-thread.h" #include "gba-video.h" -const unsigned GBA_AUDIO_SAMPLES = 512; +const unsigned GBA_AUDIO_SAMPLES = 2048; const unsigned GBA_AUDIO_FIFO_SIZE = 8 * sizeof(int32_t); #define SWEEP_CYCLES (GBA_ARM7TDMI_FREQUENCY / 128)
M src/platform/sdl/gl-main.csrc/platform/sdl/gl-main.c

@@ -85,6 +85,7 @@ }

struct GBAThread context = { .renderer = &renderer.d.d, + .audioBuffers = 512, .startCallback = _GBASDLStart, .cleanCallback = _GBASDLClean, .sync.videoFrameWait = 0,

@@ -95,6 +96,9 @@

context.debugger = createDebugger(&opts); GBAMapOptionsToContext(&opts, &context); + + renderer.audio.samples = context.audioBuffers; + GBASDLInitAudio(&renderer.audio); GBAThreadStart(&context);

@@ -115,7 +119,6 @@ return 0;

} GBASDLInitEvents(&renderer->events); - GBASDLInitAudio(&renderer->audio); #if SDL_VERSION_ATLEAST(2, 0, 0) SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
M src/platform/sdl/sdl-audio.csrc/platform/sdl/sdl-audio.c

@@ -16,7 +16,7 @@

context->desiredSpec.freq = 44100; context->desiredSpec.format = AUDIO_S16SYS; context->desiredSpec.channels = 2; - context->desiredSpec.samples = BUFFER_SIZE; + context->desiredSpec.samples = context->samples; context->desiredSpec.callback = _GBASDLAudioCallback; context->desiredSpec.userdata = context; context->audio = 0;
M src/platform/sdl/sdl-audio.hsrc/platform/sdl/sdl-audio.h

@@ -6,10 +6,15 @@

#include <SDL.h> struct GBASDLAudio { + // Input + size_t samples; + + // State SDL_AudioSpec desiredSpec; SDL_AudioSpec obtainedSpec; float drift; float ratio; + struct GBAAudio* audio; struct GBAThread* thread; };
M src/platform/sdl/sw-main.csrc/platform/sdl/sw-main.c

@@ -79,6 +79,9 @@ context.debugger = createDebugger(&opts);

GBAMapOptionsToContext(&opts, &context); + renderer.audio.samples = context.audioBuffers; + GBASDLInitAudio(&renderer.audio); + #if SDL_VERSION_ATLEAST(2, 0, 0) renderer.events.fullscreen = graphicsOpts.fullscreen; renderer.window = SDL_CreateWindow(PROJECT_NAME, SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, renderer.viewportWidth, renderer.viewportHeight, SDL_WINDOW_OPENGL | (SDL_WINDOW_FULLSCREEN_DESKTOP * renderer.events.fullscreen));

@@ -145,7 +148,6 @@ return 0;

} GBASDLInitEvents(&renderer->events); - GBASDLInitAudio(&renderer->audio); #if !SDL_VERSION_ATLEAST(2, 0, 0) #ifdef COLOR_16_BIT