Set buffer size to 512 samples in the SDL/GL port

This commit is contained in:
Jeffrey Pfau 2014-07-21 00:29:38 -07:00
parent e527220398
commit 6e727db553
5 changed files with 14 additions and 4 deletions

View File

@ -6,7 +6,7 @@
#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)

View File

@ -85,6 +85,7 @@ int main(int argc, char** argv) {
struct GBAThread context = {
.renderer = &renderer.d.d,
.audioBuffers = 512,
.startCallback = _GBASDLStart,
.cleanCallback = _GBASDLClean,
.sync.videoFrameWait = 0,
@ -96,6 +97,9 @@ int main(int argc, char** argv) {
GBAMapOptionsToContext(&opts, &context);
renderer.audio.samples = context.audioBuffers;
GBASDLInitAudio(&renderer.audio);
GBAThreadStart(&context);
_GBASDLRunloop(&context, &renderer);
@ -115,7 +119,6 @@ static int _GBASDLInit(struct GLSoftwareRenderer* renderer) {
}
GBASDLInitEvents(&renderer->events);
GBASDLInitAudio(&renderer->audio);
#if SDL_VERSION_ATLEAST(2, 0, 0)
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);

View File

@ -16,7 +16,7 @@ bool GBASDLInitAudio(struct GBASDLAudio* context) {
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;

View File

@ -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;
};

View File

@ -79,6 +79,9 @@ int main(int argc, char** argv) {
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 @@ static int _GBASDLInit(struct SoftwareRenderer* renderer) {
}
GBASDLInitEvents(&renderer->events);
GBASDLInitAudio(&renderer->audio);
#if !SDL_VERSION_ATLEAST(2, 0, 0)
#ifdef COLOR_16_BIT