Sign in to follow this  

PLZ help

This topic is 4270 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Why doesn't this openAL work! It's almost exactly the same as the sample - the sample works, this doesn't. Its been bugging me for over 3 days now! The PlaySound code works, but openAL part doesn't play the sound for some reason!
#pragma comment(lib, "OpenAL32.lib")
#pragma comment(lib, "ALut.lib")

#pragma comment(lib, "winmm.lib")

#include <windows.h>
#include <mmsystem.h>

#include <al/al.h>
#include <al/alc.h>
#include <al/alut.h>

int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
	ALuint iBuffer;
	ALuint iSource;
	ALint state;

	alGenBuffers(1, &iBuffer);

	ALsizei size, freq;
	ALenum format;
	ALvoid* data;
	ALboolean loop;

	alutLoadWAVFile("25shotgun25.wav", &format, &data, &size, &freq, &loop);

	alBufferData(iBuffer, format, data, size, freq);
	alutUnloadWAV(format, data, size, freq);

	alGenSources(1, &iSource);
	alSourcei(iSource, AL_BUFFER, iBuffer);

	MessageBox(0, "alSourcePlay", "Message", MB_OK);

	alSourcePlay(iSource);

	alGetSourcei(iSource, AL_SOURCE_STATE, &state);

	while(state == AL_PLAYING)
	{
		alGetSourcei(iSource, AL_SOURCE_STATE, &state);
	}

	MessageBox(0, "PlaySound", "Message", MB_OK);

	PlaySound("25shotgun25.wav", NULL, SND_SYNC);

	alDeleteSources(1, &iSource);

	MessageBox(0, "The End!", "Message", MB_OK);

	return 0;
}


BIG thanks to anyone, anyone who can solve this!

Share this post


Link to post
Share on other sites
This is the 4th part of a 4 part debugging scheme I drew - the original openAL comes from my game engine (I was on a roll until this crap!), the 2nd was checking the error codes - nothing comes up, openAL says everything is fine, the 3rd I though my file, "25shotgun25.wav" might be corrupted, so I plugged that name into the samples and it worked just fine. So here I am, the 4th step, testing openAL as a separate system, not distracted by DirectInput or OpenGL.

Now I'm at the point of desperation - I can't think of much more debugging to do. If this fails and I never get it working, my Game Engine is as good as trash.

PS-I'm not the master debugger, so these "steps" may seem a little weird and out of order.

Share this post


Link to post
Share on other sites
1) you should check return codes. They often give you some informations about what's wrong.

2) Since PlaySound works, this is not a path problem, so the problem lies in your openal code - almost exactly the same != the same.

Regards,

Share this post


Link to post
Share on other sites

This topic is 4270 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this