c++ - openAL looping cycle error -


im trying play looping sound in opengl/sdl openal when im calling looping infinitely , stuck @ start ive got no idea how fix came here hoping some1 knows heres code of how im calling openal

sdl_thread * audiobg;      bool init(void)     {      m_music->loadfile("sonido/bgsp.wav",true);     }      int musicthread(void *arg)//creating thread     {        arg+=0;         for(;;)         {             m_music->playsound();         }         return 0;     }  void draw()//this cycle of game {     gui->draw(x,y,z);      audiobg = sdl_createthread(music,null);  } 

this class sound.cpp

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,&alformatbuffer,                     (void **)&albuffer,                     (alsizei *)&albufferlen,                     &alfreqbuffer,&loop);      algensources(1,&this->alsource);     algenbuffers(1,&alsampleset);     albufferdata(alsampleset,alformatbuffer,albuffer,albufferlen,alfreqbuffer);     alsourcei(this->alsource,al_buffer,alsampleset);      alutunloadwav(alformatbuffer,albuffer,albufferlen,alfreqbuffer);      alsourcef(this->alsource,al_pitch,1.0f);      alsourcef(this->alsource,al_gain,1.0f);      if(looping)     alsourcei(this->alsource,al_looping,al_true);     else     alsourcei(this->alsource,al_looping,al_false); }  void sound::direction(float x,float y,float z,float vx,float vy,float vz) {     alsource3f(this->alsource,al_position,x,y,z);     alsource3f(this->alsource,al_velocity,vx,vy,vz); }  void sound::relativesound() {     alsourcei(this->alsource,al_source_relative,al_true); }  void sound::playsound() {     alsourceplay(this->alsource); } 

im lost... if call function loadfile , initialize song out of game loop , without thread plays inside loop , or without thread im getting error tried describe :s


Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -