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

nic at weartronics.com nic at weartronics.com
Sun Dec 3 19:53:14 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;
>   }
>
>
>
>
> _______________________________________________
> Openal mailing list
> Openal at opensource.creative.com
> http://opensource.creative.com/mailman/listinfo/openal
>

Hi Steve,

I think the number of sources is limited by the hardware implementation.
Unfortunately there is no way to query the maximum number of sources. When
you receive the error generating the source, you will know the maximum
number of sources for your system :)

If you run out of sources, you can ignore low priority or quiet sources or
you can mix your PCM data in software or other more efficient use of
sources.

Kind regards,

Nic


More information about the Openal mailing list