/* alcOpenDevice Open the Device specified. */ ALCAPI ALCdevice* ALCAPIENTRY alcOpenDevice(const ALCchar *deviceName) { ALboolean bDeviceFound = AL_FALSE; ALCdevice *device; ALint i; InitAL(); if(deviceName && !deviceName[0]) deviceName = NULL; device = malloc(sizeof(ALCdevice)); if (device) { const char *fmt; //Initialise device structure memset(device, 0, sizeof(ALCdevice)); //Validate device device->IsCaptureDevice = AL_FALSE; //Set output format device->Frequency = GetConfigValueInt(NULL, "frequency", SWMIXER_OUTPUT_RATE); if((ALint)device->Frequency <= 0) device->Frequency = SWMIXER_OUTPUT_RATE; fmt = GetConfigValue(NULL, "format", "AL_FORMAT_STEREO16"); if(fmt[0]) device->Format = alGetEnumValue(fmt); if(!aluChannelsFromFormat(device->Format)) device->Format = AL_FORMAT_STEREO16; device->UpdateSize = GetConfigValueInt(NULL, "refresh", 4096); if((ALint)device->UpdateSize <= 0) device->UpdateSize = 4096; device->MaxNoOfSources = GetConfigValueInt(NULL, "sources", 256); if((ALint)device->MaxNoOfSources <= 0) device->MaxNoOfSources = 256; // Find a playback device to open for(i = 0;BackendList[i].Init;i++) { device->Funcs = &BackendList[i].Funcs; if(ALCdevice_OpenPlayback(device, deviceName)) { SuspendContext(NULL); device->next = g_pDeviceList; g_pDeviceList = device; g_ulDeviceCount++; ProcessContext(NULL); bDeviceFound = AL_TRUE; break; } } if (!bDeviceFound) { // No suitable output device found SetALCError(ALC_INVALID_VALUE); free(device); device = NULL; } } else SetALCError(ALC_OUT_OF_MEMORY); return device; }
/* alcOpenDevice Open the Device specified. */ ALCAPI ALCdevice* ALCAPIENTRY alcOpenDevice(const ALCchar *deviceName) { ALboolean bDeviceFound = AL_FALSE; ALCdevice *device; ALint i; if(deviceName && !deviceName[0]) deviceName = NULL; device = malloc(sizeof(ALCdevice)); if (device) { const char *fmt; //Initialise device structure memset(device, 0, sizeof(ALCdevice)); //Validate device device->Connected = ALC_TRUE; device->IsCaptureDevice = AL_FALSE; device->Bs2b = NULL; device->szDeviceName = NULL; device->Contexts = NULL; device->NumContexts = 0; //Set output format device->Frequency = GetConfigValueInt(NULL, "frequency", SWMIXER_OUTPUT_RATE); if(device->Frequency == 0) device->Frequency = SWMIXER_OUTPUT_RATE; fmt = GetConfigValue(NULL, "format", "AL_FORMAT_STEREO16"); device->Format = GetFormatFromString(fmt); device->NumUpdates = GetConfigValueInt(NULL, "periods", 4); if(device->NumUpdates < 2) device->NumUpdates = 4; i = GetConfigValueInt(NULL, "refresh", 4096); if(i <= 0) i = 4096; device->UpdateSize = GetConfigValueInt(NULL, "period_size", i/device->NumUpdates); if(device->UpdateSize <= 0) device->UpdateSize = i/device->NumUpdates; device->MaxNoOfSources = GetConfigValueInt(NULL, "sources", 256); if((ALint)device->MaxNoOfSources <= 0) device->MaxNoOfSources = 256; device->AuxiliaryEffectSlotMax = GetConfigValueInt(NULL, "slots", 4); if((ALint)device->AuxiliaryEffectSlotMax <= 0) device->AuxiliaryEffectSlotMax = 4; device->lNumStereoSources = 1; device->lNumMonoSources = device->MaxNoOfSources - device->lNumStereoSources; device->NumAuxSends = GetConfigValueInt(NULL, "sends", MAX_SENDS); if(device->NumAuxSends > MAX_SENDS) device->NumAuxSends = MAX_SENDS; device->Bs2bLevel = GetConfigValueInt(NULL, "cf_level", 0); // Find a playback device to open SuspendContext(NULL); for(i = 0;BackendList[i].Init;i++) { device->Funcs = &BackendList[i].Funcs; if(ALCdevice_OpenPlayback(device, deviceName)) { device->next = g_pDeviceList; g_pDeviceList = device; g_ulDeviceCount++; bDeviceFound = AL_TRUE; break; } } ProcessContext(NULL); if (!bDeviceFound) { // No suitable output device found alcSetError(ALC_INVALID_VALUE); free(device); device = NULL; } } else alcSetError(ALC_OUT_OF_MEMORY); return device; }