From e30325c40f6ea482862745db0f4555e513f2952e Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Sat, 17 Oct 2009 22:36:15 +0000 Subject: Add OPL library API function to set software emulation sample rate, and set from snd_samplerate in the configuration file. Subversion-branch: /branches/opl-branch Subversion-revision: 1723 --- opl/opl_sdl.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'opl/opl_sdl.c') diff --git a/opl/opl_sdl.c b/opl/opl_sdl.c index 4a2e1ff8..2eb8288f 100644 --- a/opl/opl_sdl.c +++ b/opl/opl_sdl.c @@ -40,9 +40,6 @@ #include "opl_queue.h" -// TODO: -#define opl_sample_rate 22050 - // When the callback mutex is locked using OPL_Lock, callback functions // are not invoked. @@ -278,6 +275,20 @@ static void TimerHandler(int channel, double interval_seconds) SDL_UnlockMutex(callback_queue_mutex); } +static unsigned int GetSliceSize(void) +{ + unsigned int slicesize; + + slicesize = 1024 * (opl_sample_rate / 11025); + + if (slicesize <= 1024) + { + slicesize = 1024; + } + + return slicesize; +} + static int OPL_SDL_Init(unsigned int port_base) { // Check if SDL_mixer has been opened already @@ -291,7 +302,7 @@ static int OPL_SDL_Init(unsigned int port_base) return 0; } - if (Mix_OpenAudio(opl_sample_rate, AUDIO_S16SYS, 2, 1024) < 0) + if (Mix_OpenAudio(opl_sample_rate, AUDIO_S16SYS, 2, GetSliceSize()) < 0) { fprintf(stderr, "Error initialising SDL_mixer: %s\n", Mix_GetError()); -- cgit v1.2.3