Sign in to follow this  
xmanoux

OpenAL strange behaviour in an c++ object context

Recommended Posts

xmanoux    100
Hello!

I have a strange behaviour with using openAL in an object context.
I have identified and contourned the problem, but I don't understand what is wrong in the unfunctional version of my code.
So, if an C++ expert have an idea, I think it will help me to progress.

not working code:


class soundTransmitter
{
public:
ALuint hSource ;
soundTransmitter() //constructor
{
alGenSources(1, &hSource); //NO AL ERRORS
}
play()
{
ALuint hBuffer = alutCreateBufferFromFile("data/everybody.wav");
alSourceQueueBuffers(hSource,1,&hBuffer); //OPENAL ERROR AL_INVALID_NAME
alSourcePlay(hSource); //NO SOUND
}
}




Working code


class soundTransmitter
{
public:
ALuint hSource ;
soundTransmitter() //constructor
{
alGenSources(1, &hSource);
}
play()
{
ALuint hBuffer = alutCreateBufferFromFile("data/everybody.wav");
ALuint hSourceTMP = hSource ; //I CREATE A TEMPORY VAR TO STORE THE ATTRIBUTE INT
alSourceQueueBuffers(hSourceTMP,1,&hBuffer); //NO ERRORS
alSourcePlay(hSourceTMP); //SOUND !!!
}
}




Is anybody has an idea why, when used as a object instance attribute, an openAL int source handle crash ?

My platform is ubuntu with last openal libraries
Thanks a lot !!!

Share this post


Link to post
Share on other sites

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