From 1279acafa9116b8e6502697c80fab67d2dc4a661 Mon Sep 17 00:00:00 2001 From: Steve Date: Thu, 18 Oct 2018 07:31:40 +0100 Subject: [PATCH] Allow audio setup to be defined at compile time. --- .gitignore | 1 + src/defs.h | 16 ++++++++++++++++ src/system/init.c | 4 ++-- 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 2fd7e82..687c8fa 100644 --- a/.gitignore +++ b/.gitignore @@ -44,3 +44,4 @@ build/* # Misc .DS_Store +/.errors diff --git a/src/defs.h b/src/defs.h index 29bce90..7f2b3d2 100644 --- a/src/defs.h +++ b/src/defs.h @@ -30,6 +30,22 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define FIXED_RESOLUTION 0 #endif +#ifndef AUDIO_FREQUENCY +#define AUDIO_FREQUENCY 44100 +#endif + +#ifndef AUDIO_CHANNELS +#define AUDIO_CHANNELS 2 +#endif + +#ifndef AUDIO_CHUNKSIZE +#define AUDIO_CHUNKSIZE 1024 +#endif + +#ifndef AUDIO_MIX_CHANNELS +#define AUDIO_MIX_CHANNELS 64 +#endif + #define _(string) getTranslatedString(string) #define PI 3.14159265358979323846 diff --git a/src/system/init.c b/src/system/init.c index 9e80c9f..ce1e2c5 100644 --- a/src/system/init.c +++ b/src/system/init.c @@ -85,13 +85,13 @@ void initSDL(void) SDL_ShowCursor(0); - if (Mix_OpenAudio(44100, MIX_DEFAULT_FORMAT, 2, 1024) == -1) + if (Mix_OpenAudio(AUDIO_FREQUENCY, MIX_DEFAULT_FORMAT, AUDIO_CHANNELS, AUDIO_CHUNKSIZE) == -1) { printf("Couldn't initialize SDL Mixer\n"); exit(1); } - Mix_AllocateChannels(64); + Mix_AllocateChannels(AUDIO_MIX_CHANNELS); Mix_Volume(-1, app.soundVolume * MIX_MAX_VOLUME / 10); Mix_VolumeMusic(app.musicVolume * MIX_MAX_VOLUME / 10);