[Change] Disable sound and music if fail to initiailize. [Add] Warn if SDL_Mixer version differs.
This commit is contained in:
parent
e5d50254d2
commit
b831e311e6
@ -587,7 +587,7 @@ static void print_SDLversion(void) {
|
||||
/* Check if major/minor version differ. */
|
||||
if((linked->major*100 + linked->minor) > compiled.major*100 + compiled.minor)
|
||||
WARN("SDL is newer than compiled version.");
|
||||
if((linked->major*100 + linked->monor) < compiled.major*100 + compiled.minor)
|
||||
if((linked->major*100 + linked->minor) < compiled.major*100 + compiled.minor)
|
||||
WARN("SDL is older than compiled version.");
|
||||
}
|
||||
|
||||
|
57
src/sound.c
57
src/sound.c
@ -78,6 +78,7 @@ static alVoice* voice_active = NULL; /**< Active voices. */
|
||||
static alVoice* voice_pool = NULL; /**< Pool of free voices. */
|
||||
|
||||
/* General prototypes. */
|
||||
static void print_MixerVersion(void);
|
||||
static int sound_makeList(void);
|
||||
static Mix_Chunk* sound_load(char* filename);
|
||||
static void sound_free(alSound* snd);
|
||||
@ -94,34 +95,21 @@ static alVoice* voice_get(int id);
|
||||
* @return 0 on success.
|
||||
*/
|
||||
int sound_init(void) {
|
||||
int frequency;
|
||||
Uint16 format;
|
||||
int channels;
|
||||
SDL_version compile_version;
|
||||
const SDL_version* link_version;
|
||||
char device[PATH_MAX];
|
||||
|
||||
if(sound_disabled) return 0;
|
||||
|
||||
SDL_InitSubSystem(SDL_INIT_AUDIO);
|
||||
if(Mix_OpenAudio(44100, MIX_DEFAULT_FORMAT, 2, 1024) < 0) {
|
||||
WARN("Opening Audio: %s", Mix_GetError());
|
||||
DEBUG();
|
||||
sound_disabled = 1; /* Just disable sound then. */
|
||||
music_disabled = 1;
|
||||
return -1;
|
||||
}
|
||||
|
||||
Mix_AllocateChannels(SOUND_CHANNEL_MAX);
|
||||
|
||||
/* Debug magic. */
|
||||
Mix_QuerySpec(&frequency, &format, &channels);
|
||||
MIX_VERSION(&compile_version);
|
||||
link_version = Mix_Linked_Version();
|
||||
SDL_AudioDriverName(device, PATH_MAX);
|
||||
DEBUG("SDL_Mixer: %d.%d.%d [compiled: %d.%d.%d]",
|
||||
compile_version.major, compile_version.minor, compile_version.patch,
|
||||
link_version->major, link_version->minor, link_version->patch);
|
||||
DEBUG("Driver: %s", device);
|
||||
DEBUG("Format: %d HZ %s", frequency, (channels == 2) ? "Sterio" : "Mono");
|
||||
DEBUG();
|
||||
print_MixerVersion();
|
||||
|
||||
/* Load up all the sounds. */
|
||||
sound_makeList();
|
||||
@ -139,6 +127,41 @@ int sound_init(void) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @fn static void print_MixerVersion(void)
|
||||
*
|
||||
* @brief Print the current and compiled SDL_Mixer versions.
|
||||
*/
|
||||
static void print_MixerVersion(void) {
|
||||
int frequency;
|
||||
Uint16 format;
|
||||
int channels;
|
||||
SDL_version compiled;
|
||||
const SDL_version* linked;
|
||||
char device[PATH_MAX];
|
||||
|
||||
/* Query stuff. */
|
||||
Mix_QuerySpec(&frequency, &format, &channels);
|
||||
MIX_VERSION(&compiled);
|
||||
linked = Mix_Linked_Version();
|
||||
SDL_AudioDriverName(device, PATH_MAX);
|
||||
|
||||
/* Version itself. */
|
||||
DEBUG("SDL_Mixer: %d.%d.%d [compiled: %d.%d.%d]",
|
||||
compiled.major, compiled.minor, compiled.patch,
|
||||
linked->major, linked->minor, linked->patch);
|
||||
|
||||
/* Check if major/minor version differ. */
|
||||
if((linked->major*100 + linked->minor) > compiled.major*100 + compiled.minor)
|
||||
WARN("SDL_Mixer is newer than compiled version.");
|
||||
if((linked->major*100 + linked->minor) < compiled.major*100 + compiled.minor)
|
||||
WARN("SDL_Mixer is older than compiled version.");
|
||||
/* Print other debug info. */
|
||||
DEBUG("Driver: %s", device);
|
||||
DEBUG("Format: %d Hz %s", frequency, (channels == 2) ? "Sterio" : "Mono");
|
||||
DEBUG();
|
||||
}
|
||||
|
||||
/**
|
||||
* @fn void sound_exit(void)
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user