Allow audio setup to be defined at compile time.

This commit is contained in:
Steve 2018-10-18 07:31:40 +01:00
parent 4c0d1ab808
commit 1279acafa9
3 changed files with 19 additions and 2 deletions

1
.gitignore vendored
View File

@ -44,3 +44,4 @@ build/*
# Misc
.DS_Store
/.errors

View File

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

View File

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