all repos — mgba @ 98c8b42b0f2aa63f61dfb27d2a68bc437028b280

mGBA Game Boy Advance Emulator

Slow down audio slightly to match target FPS
Jeffrey Pfau jeffrey@endrift.com
Mon, 20 Jan 2014 20:02:44 -0800
commit

98c8b42b0f2aa63f61dfb27d2a68bc437028b280

parent

dccde662c637f403bc0e65a98b8769da18bc965b

2 files changed, 4 insertions(+), 2 deletions(-)

jump to
M src/platform/sdl/gl-main.csrc/platform/sdl/gl-main.c

@@ -95,7 +95,7 @@

GBASDLInitEvents(&renderer->events); GBASDLInitAudio(&renderer->audio); - SDL_GL_SetAttribute(SDL_GL_SWAP_CONTROL, 0); + SDL_GL_SetAttribute(SDL_GL_SWAP_CONTROL, 1); SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8); SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8); SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8);
M src/platform/sdl/sdl-audio.csrc/platform/sdl/sdl-audio.c

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

#include "gba-thread.h" #define BUFFER_SIZE (GBA_AUDIO_SAMPLES >> 2) +#define FPS_TARGET 60.f struct StereoSample { Sint16 left;

@@ -87,7 +88,8 @@ if (!context || !audioContext->audio) {

memset(data, 0, len); return; } - audioContext->ratio = audioContext->obtainedSpec.freq / (float) audioContext->audio->sampleRate; + float ratio = 280896.0f * FPS_TARGET / GBA_ARM7TDMI_FREQUENCY; + audioContext->ratio = audioContext->obtainedSpec.freq / ratio / (float) audioContext->audio->sampleRate; struct StereoSample* ssamples = (struct StereoSample*) data; len /= 2 * audioContext->obtainedSpec.channels; if (audioContext->obtainedSpec.channels == 2) {