Original Post
I''m coding a cross platform FPS with OpenAL right. Now it''s going fine, OpenAL is working fine. Then, I don''t know what I changed but I dont hear any sounds at all anymore.
Ok, so I try to isolate the problem, I can''t figure out whats wrong. So I strip it down to just this code...
ALuint sounds[10];
ALuint sources[10];
ALint audio_error;
alutInit(0, NULL);
if ((audio_error = alGetError()) != AL_NO_ERROR) {
erLogError(ER_AUDIO, "Couldn''t start OpenAL", audio_error);
}
atexit(alutExit);
alGenBuffers(10, sounds);
if ((audio_error = alGetError()) != AL_NO_ERROR) {
erLogError(ER_AUDIO, "Couldn''t start OpenAL", audio_error);
}
alGenSources(10, sources);
if ((audio_error = alGetError()) != AL_NO_ERROR) {
erLogError(ER_AUDIO, "Couldn''t start OpenAL", audio_error);
}
ALint format;
void* data;
ALsizei size, freq;
ALboolean loop;
alutLoadWAVFile("phaser.wav",&format,&data,&size,&freq,&loop);
alBufferData(sounds[0],format,data,size,freq);
alutUnloadWAV(format,data,size,freq);
alSourcei(sources[0], AL_BUFFER, sounds[0]);
alSourcei(sources[0], AL_LOOPING, AL_TRUE);
alSource3f(sources[0], AL_POSITION, 0, 0, 0);
alSource3f(sources[0], AL_VELOCITY, 0, 0, 0);
alListener3f(AL_POSITION, 0, 0, 0);
alListener3f(AL_ORIENTATION, 1, 1, 1);
alListener3f(AL_VELOCITY, 0, 0, 0);
alSourcePlay(sources[0]);
if ((audio_error = alGetError()) != AL_NO_ERROR) {
erLogError(ER_AUDIO, "Couldn''t play OpenAL source", audio_error);
}
I also used to have error checking on the load WAV but that works fine. The problem seems to be a AL_INVALID_NAME error coming from the alSourcePlay call. What the hell does that mean? In the source it says "Illegal name passed as an argument to an AL call." That just doesn''t make sense.
Any ideas whats going on here?