[Openal] openAL threading issues?

uray meiviar uraymeiviar at yahoo.com
Wed Jun 6 19:13:05 PDT 2007


consider the following codes :

ALuint source        = 0;
ALint  sourceState   = 0;
bit isrun = false;

DWORD WINAPI althread(LPVOID params)
{
    while( isrun ) {        
        alGetSourcei( source, AL_SOURCE_STATE, &sourceState);
        if(sourceState != AL_PLAYING) {
            alSourcePlay( source );
        }        
    }
    return 0;
}

void main(void)
{
    // -------- as usual rituals :
    // alcOpenDevice(NULL);
    // alcCreateContext(..)
    // alcMakeContextCurrent(..)
    // alGenBuffers(..)
    // loadWAV()
    // alBufferData(..)
    // alGenSources(..)
    // alSourcei(..,AL_BUFFER,..)

    isrun = true;
    HANDLE thread = CreateThread(NULL,0,althread,NULL,0,NULL);
    _getch();
    isrun = false;
    WaitForSingleObject(thread,INFINITE);

    // alSourceStop(..)
    // alSourcei( .., AL_BUFFER, NULL )
    // alDeleteSources(..)
    // alDeleteBuffers(..)
    // alcMakeContextCurrent(NULL)
    // alcDestroyContext(..)
    // alcCloseDevice(..)
}

sometimes the sound is played and sometime not, but no errors returned from all AL calls, i don't know if it is openAL threading issues or what, because if don't call openAL func. in different thread the sound is always played. what's wrong?



       
____________________________________________________________________________________
Get the Yahoo! toolbar and be alerted to new email wherever you're surfing.
http://new.toolbar.yahoo.com/toolbar/features/mail/index.php
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://opensource.creative.com/pipermail/openal/attachments/20070606/c5635626/attachment.html


More information about the Openal mailing list