Slow down audio slightly to match target FPS
Jeffrey Pfau jeffrey@endrift.com
Mon, 20 Jan 2014 20:02:44 -0800
2 files changed,
4 insertions(+),
2 deletions(-)
M
src/platform/sdl/gl-main.c
→
src/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.c
→
src/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) {