Skip to main content
GameDev.net gamedev.net
🔒 Locked

OpenAL problems

Started by Insodus Oct 11, 2003 at 1:56 AM 5 replies 2.2k views
Original Post
Insodus
Insodus
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?
---------------------------------"Without C, all we would have is Pasal, Basi, and obol.""Black holes are where god divided by zero."http://www.insodus.com
chbfiv
chbfiv
sources[0] NULL?

alBufferData(sounds[0],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);

Im just about to start using openAL, but I would guess sources[0] is NULL, or had a Error within one of those calls. =/
-BourkeIV
Insodus
Insodus
Indeed my friend.

I also get the AL_INVALID_NAME on the line...
alSourcei(sources[0], AL_BUFFER, sounds[0]);

I noticed the value of sounds[0] is not initialized. (Instead of something normal like 0 through 10 its 4134551) This must mean then that the file isnt being loaded correctly? Or that the alBufferData function isnt working?

[edited by - Insodus on October 11, 2003 3:34:22 AM]
---------------------------------"Without C, all we would have is Pasal, Basi, and obol.""Black holes are where god divided by zero."http://www.insodus.com
Insodus
Insodus
global
---------------------------------"Without C, all we would have is Pasal, Basi, and obol.""Black holes are where god divided by zero."http://www.insodus.com

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.