Esempio n. 1
0
void ALDeviceList::SelectBestDevice()
{
    m_defaultDeviceIndex	= -1;
    int best_majorVersion	= -1;
    int best_minorVersion	= -1;
    int majorVersion, minorVersion;
    for (int i = 0; i < GetNumDevices(); i++)
    {
        if( m_defaultDeviceName!=GetDeviceName(i) )continue;

        GetDeviceVersion		(i, &majorVersion, &minorVersion);
        if( (majorVersion>best_majorVersion) ||
                (majorVersion==best_majorVersion && minorVersion>best_minorVersion) )
        {
            best_majorVersion		= majorVersion;
            best_minorVersion		= minorVersion;
            m_defaultDeviceIndex	= i;
        }
    }
    if(m_defaultDeviceIndex==-1)
    {   // not selected
        R_ASSERT(GetNumDevices()!=0);
        m_defaultDeviceIndex = 0; //first
    };

    if(GetNumDevices()==0)
        Msg("SOUND: OpenAL: SelectBestDevice: list empty");
    else
        Msg("SOUND: OpenAL: SelectBestDevice is %s %d.%d",GetDeviceName(m_defaultDeviceIndex).c_str(),best_majorVersion,best_minorVersion);
}
Esempio n. 2
0
/* 
 * Returns the device name at an index in the complete device list
 */
char * ALDeviceList::GetDeviceName(s32 index)
{
	if (index < GetNumDevices())
		return (char *)vDeviceInfo[index].strDeviceName.c_str();
	else
		return NULL;
}
Esempio n. 3
0
/*
 * Returns the maximum number of Sources that can be generate on the given device
 */
u32 ALDeviceList::GetMaxNumSources(s32 index)
{
	if (index < GetNumDevices())
		return vDeviceInfo[index].uiSourceCount;
	else
		return 0;
}
Esempio n. 4
0
/*
 * Resets all filtering, such that all devices are in the list
 */
void ALDeviceList::ResetFilters()
{
	for (s32 i = 0; i < GetNumDevices(); i++) {
		vDeviceInfo[i].bSelected = true;
	}
	filterIndex = 0;
}
Esempio n. 5
0
/* 
 * Returns the device name at an index in the complete device list
 */
const char *ALDeviceList::GetDeviceName(int index)
{
	if (index < GetNumDevices())
		return vDeviceInfo[index].strDeviceName;
	else
		return NULL;
}
Esempio n. 6
0
/*
 * Returns the maximum number of Sources that can be generate on the given device
 */
unsigned int ALDeviceList::GetMaxNumSources(int index)
{
	if (index < GetNumDevices())
		return vDeviceInfo[index].uiSourceCount;
	else
		return 0;
}
Esempio n. 7
0
/*
 * Checks if the extension is supported on the given device
 */
bool ALDeviceList::IsExtensionSupported(int index, SFXALCaps cap)
{
	bool bReturn = false;

	if (index < GetNumDevices())
      bReturn = vDeviceInfo[index].iCapsFlags & cap;

	return bReturn;
}
Esempio n. 8
0
/*
 * Gets index of next filtered device
 */
int ALDeviceList::GetNextFilteredDevice()
{
    for (int i = m_filterIndex; i < GetNumDevices(); i++) {
        if (m_devices[i].selected == true)
            break;
    }
    m_filterIndex = i + 1;
    return i;
}
Esempio n. 9
0
/*
 * Returns the major and minor version numbers for a device at a specified index in the complete list
 */
void ALDeviceList::GetDeviceVersion(s32 index, s32 *major, s32 *minor)
{
	if (index < GetNumDevices()) {
		if (major)
			*major = vDeviceInfo[index].iMajorVersion;
		if (minor)
			*minor = vDeviceInfo[index].iMinorVersion;
	}
	return;
}
Esempio n. 10
0
/*
 * Returns the device name at an index in the complete device list
 */
char * ALDeviceList::GetDeviceName(int index)
{
	if(index < GetNumDevices())
	{
		return (char *)vDeviceInfo[index].strDeviceName.c_str();
	}
	else
	{
		return NULL;
	}
}
Esempio n. 11
0
/*
 * Gets index of first filtered device
 */
int ALDeviceList::GetFirstFilteredDevice()
{
	int i;

	for (i = 0; i < GetNumDevices(); i++) {
		if (vDeviceInfo[i].bSelected == true) {
			break;
		}
	}
	filterIndex = i + 1;
	return i;
}
Esempio n. 12
0
/*
 * Gets index of next filtered device
 */
s32 ALDeviceList::GetNextFilteredDevice()
{
	s32 i;

	for (i = filterIndex; i < GetNumDevices(); i++) {
		if (vDeviceInfo[i].bSelected == true) {
			break;
		}
	}
	filterIndex = i + 1;
	return i;
}
Esempio n. 13
0
CCameraCV::CCameraCV(int cameraId, unsigned int width, int unsigned height, 
		float fr) throw (camera_exception)
{
	if (cameraId>= GetNumDevices()) throw camera_exception("wrong camera id");
	m_Id= cameraId;
	m_Width= width;
	m_Height= height;
	m_FrameRate= fr;
	m_pCvCapture= NULL;

#if defined(WIN32)
	VfwCamFpsWorkaround ();
#endif
}
Esempio n. 14
0
CCamera* CCameraEnum::GetCamera (unsigned int id, unsigned int width,
		unsigned int height, float frameRate)
{
	if ((int) id>= GetNumDevices()) return NULL;

	try{
		return new CAMCLASS(id, width, height, frameRate);		
	} 
	catch (camera_exception &e)	{
		slog_write (SLOG_PRIO_ERR, "error initializing camera: %s\n", e.what());
	}
	
	return NULL;
}
Esempio n. 15
0
/*
 * Checks if the extension is supported on the given device
 */
bool ALDeviceList::IsExtensionSupported(s32 index, char *szExtName)
{
	bool bReturn = false;

	if (index < GetNumDevices()) {
		for (auto& ext : *vDeviceInfo[index].pvstrExtensions) {
			if (!strcasecmp(ext.c_str(), szExtName)) {
				bReturn = true;
				break;
			}
		}
	}

	return bReturn;
}
Esempio n. 16
0
/*
 * Checks if the extension is supported on the given device
 */
bool ALDeviceList::IsExtensionSupported(s32 index, char *szExtName)
{
	bool bReturn = false;

	if (index < GetNumDevices()) {
		for (u32 i = 0; i < vDeviceInfo[index].pvstrExtensions->size(); i++) {
			if (!strcasecmp(vDeviceInfo[index].pvstrExtensions->at(i).c_str(), szExtName)) {
				bReturn = true;
				break;
			}				
		}
	}

	return bReturn;
}
Esempio n. 17
0
/*
 * Returns the major and minor version numbers for a device at a specified index in the complete list
 */
void ALDeviceList::GetDeviceVersion(int index, int *major, int *minor)
{
	if(index < GetNumDevices())
	{
		if(major)
		{
			*major = vDeviceInfo[index].iMajorVersion;
		}
		if(minor)
		{
			*minor = vDeviceInfo[index].iMinorVersion;
		}
	}
	return;
}
Esempio n. 18
0
static BOOL GetNumIODevicesA( char* class_name, ULONG* num_devices )
{
    HANDLE class_handle;
    BOOL status;

    if( (NULL == class_name) || (NULL == num_devices) )
        return FALSE;

    // Get handle to device class.
    status = GetDeviceClassHandleA( class_name, &class_handle );
    if( !status )
        return FALSE;
    // Get number of devices in class.
    status = GetNumDevices( class_handle, num_devices );
    if( !status )
        return FALSE;

    return TRUE;
}//GetNumIODevicesA
IFXRESULT CIFXRenderContext::SetWindow(IFXRenderWindow& rWindow)
{
	IFXRESULT rc = IFX_OK;
	static BOOL bInReset = FALSE;

	if(m_ppRender[m_uCurrentDevice].IsValid())
	{
		rc = m_ppRender[m_uCurrentDevice]->SetWindow(rWindow);
	}

	if(IFX_E_NEED_RESET == rc)
	{
		if(!bInReset)
		{
			bInReset = TRUE;
			m_pRS->Reset();

			U32 uNumDevices = 0;
			rc = GetNumDevices(rWindow, uNumDevices);

			if(IFXSUCCESS(rc))
			{
				rc = SetWindow(rWindow);
			}
		}
		else
		{
			bInReset = FALSE;
			rc = IFX_E_SUBSYSTEM_FAILURE;
		}
	}

	if(IFXFAILURE(rc))
	{
		m_pRS->Reset();
	}

	IFXASSERTBOXEX(IFXSUCCESS(rc), "Failed SetWindow", FALSE, TRUE);

	return rc;
}
Esempio n. 20
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();
}
Esempio n. 21
0
char* CCameraCV::GetDeviceName (unsigned int id)
{
	if ((int) id>= GetNumDevices()) return NULL;	
	return g_deviceNames[id];
}
Esempio n. 22
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();
}
Esempio n. 23
0
/*
 * Resets all filtering, such that all devices are in the list
 */
void ALDeviceList::ResetFilters()
{
    for (int i = 0; i < GetNumDevices(); i++)
        m_devices[i].selected = true;
    m_filterIndex = 0;
}
Esempio n. 24
0
void ALDeviceList::Enumerate()
{
    char *devices;
    int major, minor, index;
    const char *actualDeviceName;

    Msg("SOUND: OpenAL: enumerate devices...");
    // have a set of vectors storing the device list, selection status, spec version #, and XRAM support status
    // -- empty all the lists and reserve space for 10 devices
    m_devices.clear				();

    CoUninitialize();
    // grab function pointers for 1.0-API functions, and if successful proceed to enumerate all devices
    if (alcIsExtensionPresent(NULL, "ALC_ENUMERATION_EXT"))
    {
        Msg("SOUND: OpenAL: EnumerationExtension Present");

        devices				= (char *)alcGetString(NULL, ALC_DEVICE_SPECIFIER);
        Msg					("devices %s",devices);
        m_defaultDeviceName	= (char *)alcGetString(NULL, ALC_DEFAULT_DEVICE_SPECIFIER);
        Msg("SOUND: OpenAL: system  default SndDevice name is %s", m_defaultDeviceName.c_str());

        // ManowaR
        // "Generic Hardware" device on software AC'97 codecs introduce
        // high CPU usage ( up to 30% ) as a consequence - freezes, FPS drop
        // So if default device is "Generic Hardware" which maps to DirectSound3D interface
        // We re-assign it to "Generic Software" to get use of old good DirectSound interface
        // This makes 3D-sound processing unusable on cheap AC'97 codecs
        // Also we assume that if "Generic Hardware" exists, than "Generic Software" is also exists
        // Maybe wrong

        if(0==stricmp(m_defaultDeviceName.c_str(),AL_GENERIC_HARDWARE))
        {
            m_defaultDeviceName			= AL_GENERIC_SOFTWARE;
            Msg("SOUND: OpenAL: default SndDevice name set to %s", m_defaultDeviceName.c_str());
        }

        index				= 0;
        // go through device list (each device terminated with a single NULL, list terminated with double NULL)
        while (*devices != NULL)
        {
            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);

                    if ( (actualDeviceName != NULL) && xr_strlen(actualDeviceName)>0 )
                    {
                        alcGetIntegerv					(device, ALC_MAJOR_VERSION, sizeof(int), &major);
                        alcGetIntegerv					(device, ALC_MINOR_VERSION, sizeof(int), &minor);
                        m_devices.push_back				(ALDeviceDesc(actualDeviceName,minor,major));
                        m_devices.back().xram			= (alIsExtensionPresent("EAX-RAM") == TRUE);
                        m_devices.back().eax			= (alIsExtensionPresent("EAX2.0") == TRUE);
                        // KD: disable unwanted eax flag to force eax on all devices
                        m_devices.back().eax_unwanted	= 0;/*((0==xr_strcmp(actualDeviceName,AL_GENERIC_HARDWARE))||
														   (0==xr_strcmp(actualDeviceName,AL_GENERIC_SOFTWARE)));*/
                        ++index;
                    }
                    alcDestroyContext(context);
                } else
                    Msg("SOUND: OpenAL: cant create context for %s",device);
                alcCloseDevice(device);
            } else
                Msg("SOUND: OpenAL: cant open device %s",devices);

            devices		+= xr_strlen(devices) + 1;
        }
    } else
        Msg("SOUND: OpenAL: EnumerationExtension NOT Present");

    ResetFilters();

    if(0!=GetNumDevices())
        Msg("SOUND: OpenAL: All available devices:");

    int majorVersion, minorVersion;
    for (int i = 0; i < GetNumDevices(); i++)
    {
        GetDeviceVersion		(i, &majorVersion, &minorVersion);
        Msg	("%d. %s, Spec Version %d.%d %s",
             i+1,
             GetDeviceName(i).c_str(),
             majorVersion,
             minorVersion,
             (GetDeviceName(i)==m_defaultDeviceName)? "(default)":"" );
    }
    CoInitializeEx (NULL, COINIT_MULTITHREADED);
}