[Fix] [Phase 3] Sound is enabled by default again.

This commit is contained in:
Allanis 2013-06-04 16:40:30 +01:00
parent 2ac26a5aed
commit f191a1d824
2 changed files with 12 additions and 22 deletions

View File

@ -84,7 +84,7 @@ void conf_setDefaults(void) {
gl_screen.h = 600;
gl_screen.flags = 0;
// Openal.
nosound = 1; // TODO: make sound default when it's sane again.
nosound = 0;
// Joystick.
indjoystick = -1;
namjoystick = NULL;

View File

@ -78,11 +78,8 @@ static SDL_Thread* music_player = NULL;
static alSound* sound_list = NULL;
static int nsound_list = 0;
typedef struct VoiceSource_ {
ALuint source; // Allocated source.
ALuint voice; // Voice id.
} VoiceSource;
static VoiceSource* source_stack = NULL; // And it's stack.
// Struct to hold all the sources and currently attached voice.
static ALuint* source_stack = NULL; // And it's stack.
static int source_nstack = 0;
// Virtual voice.
@ -162,7 +159,6 @@ int sound_init(void) {
// Start the music server.
music_init();
#if 0
// Start allocating the sources - music has already taken this.
alGetError(); // Another error clear.
mem = 0;
@ -170,16 +166,14 @@ int sound_init(void) {
if(mem < source_nstack+1) {
// Allocate more memory.
mem += 32;
source_stack = realloc(source_stack, sizeof(VoiceSource) * mem);
source_stack = realloc(source_stack, sizeof(ALuint) * mem);
}
alGenSources(1, &source_stack[source_nstack].source);
source_stack[source_nstack].voice = 0;
alGenSources(1, &source_stack[source_nstack]);
source_nstack++;
}
// Use minimal ram.
source_stack = realloc(source_stack, sizeof(VoiceSource) * source_nstack);
#endif
source_stack = realloc(source_stack, sizeof(ALuint) * source_nstack);
// Debug magic.
DEBUG("OpenAL: %s", device);
@ -379,8 +373,7 @@ void sound_update(void) {
if(stat == AL_PLAYING) alSourceStop(voice->source);
// Clear it and get rid of it.
alDeleteSources(1, &voice->source);
voice->source = 0;
source_stack[source_nstack++] == voice->source; // throw it back.
}
// Delete from linked list.
@ -417,14 +410,10 @@ static int voice_getSource(alVoice* voc) {
SDL_mutexP(sound_lock);
// Try and grab a source.
voc->source = 0;
alGenSources(1, &voc->source);
err = alGetError();
if(source_nstack > 0) { // We have the source.
// We must pull it from the free source vector.
voc->source = source_stack[--source_nstack];
if(err != AL_NO_ERROR) {
voc->source = 0;
ret = 1;
} else {
// Set the properties.
alSourcei(voc->source, AL_BUFFER, voc->buffer);
@ -447,7 +436,8 @@ static int voice_getSource(alVoice* voc) {
err = alGetError();
if(err == AL_NO_ERROR) voice_set(voc, VOICE_PLAYING);
else ret = 2;
}
} else
voc->source = 0;
SDL_mutexV(sound_lock);
return ret;