Note that there are some explanatory texts on larger screens.

plurals
  1. POopenAL looping cycle error
    text
    copied!<p>im trying to play a looping sound in openGL/SDL with openAL but when im calling it its just looping infinitely and its stuck at the start ive got no idea how to fix this so i came here hoping some1 knows heres my code of how im calling openAL</p> <pre><code>SDL_Thread * AudioBG; bool Init(void) { m_Music-&gt;LoadFile("Sonido/BGSP.wav",true); } int MusicThread(void *arg)//Creating the Thread { arg+=0; for(;;) { m_Music-&gt;PlaySound(); } return 0; } void Draw()//this is my cycle of the game { gui-&gt;Draw(x,y,z); AudioBG = SDL_CreateThread(Music,NULL); } </code></pre> <p>this is my class Sound.cpp</p> <pre><code>Sound::Sound() { Device = alcOpenDevice((ALCchar*)"DirectSound3D"); Context = alcCreateContext(Device,NULL); alcMakeContextCurrent(Context); alGetError(); } Sound::~Sound() { Context = alcGetCurrentContext(); Device = alcGetContextsDevice(Context); alcMakeContextCurrent(NULL); alcDestroyContext(Context); alcCloseDevice(Device); } void Sound::LoadFile(char archivo[40],bool looping) { ALboolean loop; loop = looping; alutLoadWAVFile(archivo,&amp;alFormatBuffer, (void **)&amp;alBuffer, (ALsizei *)&amp;alBufferLen, &amp;alFreqBuffer,&amp;loop); alGenSources(1,&amp;this-&gt;alSource); alGenBuffers(1,&amp;alSampleSet); alBufferData(alSampleSet,alFormatBuffer,alBuffer,alBufferLen,alFreqBuffer); alSourcei(this-&gt;alSource,AL_BUFFER,alSampleSet); alutUnloadWAV(alFormatBuffer,alBuffer,alBufferLen,alFreqBuffer); alSourcef(this-&gt;alSource,AL_PITCH,1.0f); alSourcef(this-&gt;alSource,AL_GAIN,1.0f); if(looping) alSourcei(this-&gt;alSource,AL_LOOPING,AL_TRUE); else alSourcei(this-&gt;alSource,AL_LOOPING,AL_FALSE); } void Sound::Direction(float x,float y,float z,float vx,float vy,float vz) { alSource3f(this-&gt;alSource,AL_POSITION,x,y,z); alSource3f(this-&gt;alSource,AL_VELOCITY,vx,vy,vz); } void Sound::RelativeSound() { alSourcei(this-&gt;alSource,AL_SOURCE_RELATIVE,AL_TRUE); } void Sound::PlaySound() { alSourcePlay(this-&gt;alSource); } </code></pre> <p>im really lost... if i call the function LoadFile and initialize the song out of the game loop and without a thread it plays well but inside the loop and with or without the thread im getting the error i tried to describe :S</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload