• Advertisement
Sign in to follow this  

OpenAL strange behaviour in an c++ object context

This topic is 2622 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

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
Advertisement
Sign in to follow this  

  • Advertisement