[Openal] alGenSources () problem - Number of sources can be generated?

steve steve at astrocorp.com.tw
Sun Dec 3 19:27:50 PST 2006


Hi:
My program stops while calling OpenAL generate sound source.
I also use Win32 & Winsock2 & Ogre graphic engine.

I tested it by gerenating several sound sources at the beginning.

Steve
=============================================
Init ()
{
    Gal::SoundManager::Init (NULL);

    for (int i = 0; i<100; ++i)
    {
      ALuint id;
    alGenSources (1, &id);	// ---> Error here, I = 14.
    CHECK_AL_ERROR ();	// OpenAL check error code, "Invalide value"
    }
}

SoundManger::Init () works because it reports no error and my program play
sounds ok.

  bool SoundManager::Init (char *szErr)
  {
    ALint	  error;

    // 1. Open a default device by Name
    s_pDevice = alcOpenDevice (NULL); 
    if (s_pDevice == NULL)
    {
      if (szErr)
	sprintf (szErr, "Failed to Open Device\n");
      return false;
    }

    // 2. Create context(s)
    s_pContext = alcCreateContext (s_pDevice, NULL);
    if (s_pContext == NULL)
    {
      if (szErr)
	sprintf (szErr, "Failed to create Context\n");
      return false;
    }

    // 3. Set active context
    alcGetError (s_pDevice);
    alcMakeContextCurrent (s_pContext);

    if (alcGetError(s_pDevice) != ALC_NO_ERROR)
    {
      if (szErr)
	sprintf (szErr, "Failed to Make Current context\n");
      return false;
    }

    // 4. Clear Error Code
    alGetError ();
    alcGetError (s_pDevice);

    // Set Listener attributes
    ALfloat listenerPos[]={ 0.0, 0.0, 0.0};
    ALfloat listenerVel[]={ 0.0, 0.0, 0.0};
    ALfloat listenerOri[]={0.0,0.0,-1.0, 0.0,1.0,0.0};	// Listener facing
into the screen

    alListenerfv (AL_POSITION, listenerPos);
    CHECK_ERROR_STR ("alListenerfv POSITION : ");

    alListenerfv (AL_VELOCITY,listenerVel);
    CHECK_ERROR_STR ("alListenerfv VELOCITY : ");

    alListenerfv (AL_ORIENTATION,listenerOri);
    CHECK_ERROR_STR ("alListenerfv ORIENTATION : ");

    return true;
  }






More information about the Openal mailing list