示例#1
0
/* 
 * Init call
 */
ALDeviceList::ALDeviceList()
{
	ALDEVICEINFO	ALDeviceInfo;
	char *devices;
	s32 index;
	const char *defaultDeviceName = NULL;
	const char *actualDeviceName = NULL;

	// DeviceInfo vector stores, for each enumerated device, it's device name, selection status, spec version #, and extension support
	vDeviceInfo.empty();
	vDeviceInfo.reserve(10);

	defaultDeviceIndex = 0;

	// grab function pointers for 1.0-API functions, and if successful proceed to enumerate all devices
	//if (LoadOAL10Library(NULL, &ALFunction) == TRUE) {
		if (alcIsExtensionPresent(NULL, "ALC_ENUMERATION_EXT"))
		{
			devices = (char *)alcGetString(NULL, ALC_DEVICE_SPECIFIER);
			defaultDeviceName = (char *)alcGetString(NULL, ALC_DEFAULT_DEVICE_SPECIFIER);
			index = 0;
			// go through device list (each device terminated with a single NULL, list terminated with double NULL)
			while (devices != NULL && strlen(devices) > 0) 
			{
				if (strcmp(defaultDeviceName, devices) == 0) 
				{
					defaultDeviceIndex = index;
				}
				ALCdevice *device = alcOpenDevice(devices);
				if (device) 
				{
					ALCcontext *context = alcCreateContext(device, NULL);
					if (context) 
					{
						alcMakeContextCurrent(context);
						// if new actual device name isn't already in the list, then add it...
						actualDeviceName = alcGetString(device, ALC_DEVICE_SPECIFIER);
						bool bNewName = true;
						for (s32 i = 0; i < GetNumDevices(); i++) 
						{
							if (strcmp(GetDeviceName(i), actualDeviceName) == 0) 
							{
								bNewName = false;
							}
						}
						if ((bNewName) && (actualDeviceName != NULL) && (strlen(actualDeviceName) > 0)) 
						{
							ALDeviceInfo.bSelected = true;
							ALDeviceInfo.strDeviceName = actualDeviceName;
							alcGetIntegerv(device, ALC_MAJOR_VERSION, sizeof(s32), &ALDeviceInfo.iMajorVersion);
							alcGetIntegerv(device, ALC_MINOR_VERSION, sizeof(s32), &ALDeviceInfo.iMinorVersion);

							ALDeviceInfo.pvstrExtensions = new vector<string>;

							// Check for ALC Extensions
							if (alcIsExtensionPresent(device, "ALC_EXT_CAPTURE") == AL_TRUE)
								ALDeviceInfo.pvstrExtensions->push_back("ALC_EXT_CAPTURE");
							if (alcIsExtensionPresent(device, "ALC_EXT_EFX") == AL_TRUE)
								ALDeviceInfo.pvstrExtensions->push_back("ALC_EXT_EFX");

							// Check for AL Extensions
							if (alIsExtensionPresent("AL_EXT_OFFSET") == AL_TRUE)
								ALDeviceInfo.pvstrExtensions->push_back("AL_EXT_OFFSET");

							if (alIsExtensionPresent("AL_EXT_LINEAR_DISTANCE") == AL_TRUE)
								ALDeviceInfo.pvstrExtensions->push_back("AL_EXT_LINEAR_DISTANCE");
							if (alIsExtensionPresent("AL_EXT_EXPONENT_DISTANCE") == AL_TRUE)
								ALDeviceInfo.pvstrExtensions->push_back("AL_EXT_EXPONENT_DISTANCE");
							
							if (alIsExtensionPresent("EAX2.0") == AL_TRUE)
								ALDeviceInfo.pvstrExtensions->push_back("EAX2.0");
							if (alIsExtensionPresent("EAX3.0") == AL_TRUE)
								ALDeviceInfo.pvstrExtensions->push_back("EAX3.0");
							if (alIsExtensionPresent("EAX4.0") == AL_TRUE)
								ALDeviceInfo.pvstrExtensions->push_back("EAX4.0");
							if (alIsExtensionPresent("EAX5.0") == AL_TRUE)
								ALDeviceInfo.pvstrExtensions->push_back("EAX5.0");

							if (alIsExtensionPresent("EAX-RAM") == AL_TRUE)
								ALDeviceInfo.pvstrExtensions->push_back("EAX-RAM");

							// Get Source Count
							ALDeviceInfo.uiSourceCount = GetMaxNumSources();

							vDeviceInfo.push_back(ALDeviceInfo);
						}
						alcMakeContextCurrent(NULL);
						alcDestroyContext(context);
					}
					alcCloseDevice(device);
				}
				devices += strlen(devices) + 1;
				index += 1;
			}
		}
	//}

	ResetFilters();
}
示例#2
0
/* 
 * Init call
 */
ALDeviceList::ALDeviceList( const OPENALFNTABLE &oalft )
{
   VECTOR_SET_ASSOCIATION( vDeviceInfo );

	ALDEVICEINFO	ALDeviceInfo;
	char *devices;
	int index;
	const char *defaultDeviceName;
   const char *actualDeviceName;

   dMemcpy( &ALFunction, &oalft, sizeof( OPENALFNTABLE ) );

   // DeviceInfo vector stores, for each enumerated device, it's device name, selection status, spec version #, and extension support
   vDeviceInfo.clear();
   vDeviceInfo.reserve(10);

   defaultDeviceIndex = 0;

   // grab function pointers for 1.0-API functions, and if successful proceed to enumerate all devices
   if (ALFunction.alcIsExtensionPresent(NULL, "ALC_ENUMERATION_EXT")) {
      devices = (char *)ALFunction.alcGetString(NULL, ALC_DEVICE_SPECIFIER);
      defaultDeviceName = (char *)ALFunction.alcGetString(NULL, ALC_DEFAULT_DEVICE_SPECIFIER);
      index = 0;
      // go through device list (each device terminated with a single NULL, list terminated with double NULL)
      while (*devices != 0) {
         if (dStrcmp(defaultDeviceName, devices) == 0) {
            defaultDeviceIndex = index;
         }
         ALCdevice *device = ALFunction.alcOpenDevice(devices);
         if (device) {
            ALCcontext *context = ALFunction.alcCreateContext(device, NULL);
            if (context) {
               ALFunction.alcMakeContextCurrent(context);
               // if new actual device name isn't already in the list, then add it...
               actualDeviceName = ALFunction.alcGetString(device, ALC_DEVICE_SPECIFIER);
               bool bNewName = true;
               for (int i = 0; i < GetNumDevices(); i++) {
                  if (dStrcmp(GetDeviceName(i), actualDeviceName) == 0) {
                     bNewName = false;
                  }
               }
               if ((bNewName) && (actualDeviceName != NULL) && (dStrlen(actualDeviceName) > 0)) {
                  dMemset(&ALDeviceInfo, 0, sizeof(ALDEVICEINFO));
                  ALDeviceInfo.bSelected = true;
                  dStrncpy(ALDeviceInfo.strDeviceName, actualDeviceName, sizeof(ALDeviceInfo.strDeviceName));
                  ALFunction.alcGetIntegerv(device, ALC_MAJOR_VERSION, sizeof(int), &ALDeviceInfo.iMajorVersion);
                  ALFunction.alcGetIntegerv(device, ALC_MINOR_VERSION, sizeof(int), &ALDeviceInfo.iMinorVersion);

                  ALDeviceInfo.iCapsFlags = 0;

                  // Check for ALC Extensions
                  if (ALFunction.alcIsExtensionPresent(device, "ALC_EXT_CAPTURE") == AL_TRUE)
                     ALDeviceInfo.iCapsFlags |= SFXALCapture;
                  if (ALFunction.alcIsExtensionPresent(device, "ALC_EXT_EFX") == AL_TRUE)
                     ALDeviceInfo.iCapsFlags |= SFXALEFX;

                  // Check for AL Extensions
                  if (ALFunction.alIsExtensionPresent("AL_EXT_OFFSET") == AL_TRUE)
                     ALDeviceInfo.iCapsFlags |= SFXALOffset;

                  if (ALFunction.alIsExtensionPresent("AL_EXT_LINEAR_DISTANCE") == AL_TRUE)
                     ALDeviceInfo.iCapsFlags |= SFXALLinearDistance;
                  if (ALFunction.alIsExtensionPresent("AL_EXT_EXPONENT_DISTANCE") == AL_TRUE)
                     ALDeviceInfo.iCapsFlags |= SFXALExponentDistance;

                  if (ALFunction.alIsExtensionPresent("EAX2.0") == AL_TRUE)
                     ALDeviceInfo.iCapsFlags |= SFXALEAX2;
                  if (ALFunction.alIsExtensionPresent("EAX3.0") == AL_TRUE)
                     ALDeviceInfo.iCapsFlags |= SFXALEAX3;
                  if (ALFunction.alIsExtensionPresent("EAX4.0") == AL_TRUE)
                     ALDeviceInfo.iCapsFlags |= SFXALEAX4;
                  if (ALFunction.alIsExtensionPresent("EAX5.0") == AL_TRUE)
                     ALDeviceInfo.iCapsFlags |= SFXALEAX5;

                  if (ALFunction.alIsExtensionPresent("EAX-RAM") == AL_TRUE)
                     ALDeviceInfo.iCapsFlags |= SFXALEAXRAM;

                  // Get Source Count
                  ALDeviceInfo.uiSourceCount = GetMaxNumSources();

                  vDeviceInfo.push_back(ALDeviceInfo);
               }
               ALFunction.alcMakeContextCurrent(NULL);
               ALFunction.alcDestroyContext(context);
            }
            ALFunction.alcCloseDevice(device);
         }
         devices += dStrlen(devices) + 1;
         index += 1;
      }
   }

	ResetFilters();
}