Store a copy of the device name in the device

This commit is contained in:
Chris Robinson 2009-08-27 02:53:09 -07:00
parent 45dc804819
commit 6bb14e45ce
10 changed files with 38 additions and 29 deletions

View File

@ -586,6 +586,8 @@ ALCAPI ALCdevice* ALCAPIENTRY alcCaptureOpenDevice(const ALCchar *deviceName, AL
pDevice->Connected = ALC_TRUE;
pDevice->IsCaptureDevice = AL_TRUE;
pDevice->szDeviceName = NULL;
pDevice->Frequency = frequency;
pDevice->Format = format;
pDevice->BufferSize = SampleSize;
@ -637,6 +639,8 @@ ALCAPI ALCboolean ALCAPIENTRY alcCaptureCloseDevice(ALCdevice *pDevice)
ProcessContext(NULL);
free(pDevice->szDeviceName);
ALCdevice_CloseCapture(pDevice);
free(pDevice);
@ -1378,6 +1382,8 @@ ALCAPI ALCdevice* ALCAPIENTRY alcOpenDevice(const ALCchar *deviceName)
device->Connected = ALC_TRUE;
device->IsCaptureDevice = AL_FALSE;
device->szDeviceName = NULL;
//Set output format
device->Frequency = GetConfigValueInt(NULL, "frequency", SWMIXER_OUTPUT_RATE);
if(device->Frequency == 0)
@ -1498,6 +1504,8 @@ ALCAPI ALCboolean ALCAPIENTRY alcCloseDevice(ALCdevice *pDevice)
ReleaseALDatabuffers(pDevice);
}
free(pDevice->szDeviceName);
//Release device structure
memset(pDevice, 0, sizeof(ALCdevice));
free(pDevice);

View File

@ -352,6 +352,7 @@ static ALuint ALSANoMMapCaptureProc(ALvoid *ptr)
static ALCboolean alsa_open_playback(ALCdevice *device, const ALCchar *deviceName)
{
const char *devName = alsaDevice;
alsa_data *data;
char driver[64];
int i;
@ -370,21 +371,16 @@ static ALCboolean alsa_open_playback(ALCdevice *device, const ALCchar *deviceNam
if(allDevNameMap[idx].name &&
strcmp(deviceName, allDevNameMap[idx].name) == 0)
{
device->szDeviceName = allDevNameMap[idx].name;
devName = allDevNameMap[idx].name;
if(idx > 0)
sprintf(driver, "hw:%d,%d", allDevNameMap[idx].card, allDevNameMap[idx].dev);
goto open_alsa;
}
}
if(strcmp(deviceName, alsaDevice) == 0)
{
device->szDeviceName = alsaDevice;
goto open_alsa;
}
return ALC_FALSE;
}
else
device->szDeviceName = alsaDevice;
open_alsa:
data = (alsa_data*)calloc(1, sizeof(alsa_data));
@ -408,6 +404,7 @@ open_alsa:
return ALC_FALSE;
}
device->szDeviceName = strdup(devName);
device->ExtraData = data;
return ALC_TRUE;
}
@ -582,6 +579,7 @@ static void alsa_stop_context(ALCdevice *device, ALCcontext *context)
static ALCboolean alsa_open_capture(ALCdevice *pDevice, const ALCchar *deviceName)
{
const char *devName;
snd_pcm_hw_params_t *p;
snd_pcm_uframes_t bufferSizeInFrames;
ALuint frameSize;
@ -604,7 +602,7 @@ static ALCboolean alsa_open_capture(ALCdevice *pDevice, const ALCchar *deviceNam
if(allCaptureDevNameMap[idx].name &&
strcmp(deviceName, allCaptureDevNameMap[idx].name) == 0)
{
pDevice->szDeviceName = allCaptureDevNameMap[idx].name;
devName = allCaptureDevNameMap[idx].name;
if(idx > 0)
sprintf(driver, "plughw:%d,%d", allCaptureDevNameMap[idx].card, allCaptureDevNameMap[idx].dev);
goto open_alsa;
@ -613,7 +611,7 @@ static ALCboolean alsa_open_capture(ALCdevice *pDevice, const ALCchar *deviceNam
return ALC_FALSE;
}
else
pDevice->szDeviceName = allCaptureDevNameMap[0].name;
devName = allCaptureDevNameMap[0].name;
open_alsa:
data = (alsa_data*)calloc(1, sizeof(alsa_data));
@ -730,6 +728,7 @@ open_alsa:
return ALC_FALSE;
}
pDevice->szDeviceName = strdup(devName);
return ALC_TRUE;
}

View File

@ -151,6 +151,7 @@ static ALuint DSoundProc(ALvoid *ptr)
static ALCboolean DSoundOpenPlayback(ALCdevice *device, const ALCchar *deviceName)
{
DSoundData *pData = NULL;
const char *devName;
LPGUID guid = NULL;
HRESULT hr;
@ -164,7 +165,7 @@ static ALCboolean DSoundOpenPlayback(ALCdevice *device, const ALCchar *deviceNam
{
if(strcmp(deviceName, DeviceList[i].name) == 0)
{
device->szDeviceName = DeviceList[i].name;
devName = DeviceList[i].name;
if(i > 0)
guid = &DeviceList[i].guid;
break;
@ -174,7 +175,7 @@ static ALCboolean DSoundOpenPlayback(ALCdevice *device, const ALCchar *deviceNam
return ALC_FALSE;
}
else
device->szDeviceName = DeviceList[0].name;
devName = DeviceList[0].name;
//Initialise requested device
@ -197,6 +198,7 @@ static ALCboolean DSoundOpenPlayback(ALCdevice *device, const ALCchar *deviceNam
return ALC_FALSE;
}
device->szDeviceName = strdup(devName);
device->ExtraData = pData;
return ALC_TRUE;
}

View File

@ -147,6 +147,7 @@ static ALuint OSSCaptureProc(ALvoid *ptr)
static ALCboolean oss_open_playback(ALCdevice *device, const ALCchar *deviceName)
{
const char *devName = oss_device;
char driver[64];
oss_data *data;
@ -156,10 +157,8 @@ static ALCboolean oss_open_playback(ALCdevice *device, const ALCchar *deviceName
{
if(strcmp(deviceName, oss_device))
return ALC_FALSE;
device->szDeviceName = oss_device;
devName = oss_device;
}
else
device->szDeviceName = oss_device;
data = (oss_data*)calloc(1, sizeof(oss_data));
data->killNow = 0;
@ -172,6 +171,7 @@ static ALCboolean oss_open_playback(ALCdevice *device, const ALCchar *deviceName
return ALC_FALSE;
}
device->szDeviceName = strdup(devName);
device->ExtraData = data;
return ALC_TRUE;
}
@ -299,6 +299,7 @@ static void oss_stop_context(ALCdevice *device, ALCcontext *context)
static ALCboolean oss_open_capture(ALCdevice *device, const ALCchar *deviceName)
{
const char *devName = oss_device_capture;
int numFragmentsLogSize;
int log2FragmentSize;
unsigned int periods;
@ -318,10 +319,8 @@ static ALCboolean oss_open_capture(ALCdevice *device, const ALCchar *deviceName)
{
if(strcmp(deviceName, oss_device_capture))
return ALC_FALSE;
device->szDeviceName = oss_device_capture;
devName = oss_device_capture;
}
else
device->szDeviceName = oss_device_capture;
data = (oss_data*)calloc(1, sizeof(oss_data));
data->killNow = 0;
@ -411,6 +410,7 @@ static ALCboolean oss_open_capture(ALCdevice *device, const ALCchar *deviceName)
return ALC_FALSE;
}
device->szDeviceName = strdup(devName);
return ALC_TRUE;
}

View File

@ -89,8 +89,6 @@ static ALCboolean pa_open_playback(ALCdevice *device, const ALCchar *deviceName)
return ALC_FALSE;
}
device->szDeviceName = pa_device;
data = (pa_data*)calloc(1, sizeof(pa_data));
device->ExtraData = data;
@ -143,6 +141,7 @@ static ALCboolean pa_open_playback(ALCdevice *device, const ALCchar *deviceName)
return ALC_FALSE;
}
device->szDeviceName = strdup(pa_device);
device->UpdateSize = device->BufferSize/periods;
return ALC_TRUE;
}

View File

@ -216,9 +216,6 @@ static ALCboolean pulse_open(ALCdevice *device, const ALCchar *device_name) //{{
else
data->context_name = "OpenAL Soft";
device->ExtraData = data;
device->szDeviceName = device_name;
if(!(data->loop = ppa_threaded_mainloop_new()))
{
AL_PRINT("pa_threaded_mainloop_new() failed!\n");
@ -275,6 +272,9 @@ static ALCboolean pulse_open(ALCdevice *device, const ALCchar *device_name) //{{
ppa_threaded_mainloop_accept(data->loop);
}
device->szDeviceName = strdup(device_name);
device->ExtraData = data;
ppa_threaded_mainloop_unlock(data->loop);
return ALC_TRUE;

View File

@ -92,6 +92,7 @@ static ALuint SolarisProc(ALvoid *ptr)
static ALCboolean solaris_open_playback(ALCdevice *device, const ALCchar *deviceName)
{
const char *devName = solaris_device;
audio_info_t info;
ALuint frameSize;
char driver[64];
@ -104,10 +105,8 @@ static ALCboolean solaris_open_playback(ALCdevice *device, const ALCchar *device
{
if(strcmp(deviceName, solaris_device))
return ALC_FALSE;
device->szDeviceName = solaris_device;
devName = solaris_device;
}
else
device->szDeviceName = solaris_device;
data = (solaris_data*)calloc(1, sizeof(solaris_data));
data->killNow = 0;
@ -194,6 +193,7 @@ static ALCboolean solaris_open_playback(ALCdevice *device, const ALCchar *device
return ALC_FALSE;
}
device->szDeviceName = strdup(devName);
return ALC_TRUE;
}

View File

@ -108,6 +108,7 @@ static ALuint WaveProc(ALvoid *ptr)
static ALCboolean wave_open_playback(ALCdevice *device, const ALCchar *deviceName)
{
const char *devName = waveDevice;
wave_data *data;
const char *fname;
@ -119,10 +120,8 @@ static ALCboolean wave_open_playback(ALCdevice *device, const ALCchar *deviceNam
{
if(strcmp(deviceName, waveDevice) != 0)
return ALC_FALSE;
device->szDeviceName = waveDevice;
devName = waveDevice;
}
else
device->szDeviceName = waveDevice;
data = (wave_data*)calloc(1, sizeof(wave_data));
@ -134,6 +133,7 @@ static ALCboolean wave_open_playback(ALCdevice *device, const ALCchar *deviceNam
return ALC_FALSE;
}
device->szDeviceName = strdup(devName);
device->ExtraData = data;
return ALC_TRUE;
}

View File

@ -198,7 +198,6 @@ static ALCboolean WinMMOpenCapture(ALCdevice *pDevice, const ALCchar *deviceName
if(i == NumCaptureDevices)
return ALC_FALSE;
}
pDevice->szDeviceName = CaptureDeviceList[lDeviceID];
pData = calloc(1, sizeof(*pData));
if(!pData)
@ -268,6 +267,7 @@ static ALCboolean WinMMOpenCapture(ALCdevice *pDevice, const ALCchar *deviceName
if (pData->hWaveInThread == NULL)
goto failure;
pDevice->szDeviceName = strdup(CaptureDeviceList[lDeviceID]);
return ALC_TRUE;
failure:
@ -291,6 +291,7 @@ failure:
CloseHandle(pData->hWaveInThreadEvent);
free(pData);
pDevice->ExtraData = NULL;
return ALC_FALSE;
}

View File

@ -187,7 +187,7 @@ struct ALCdevice_struct
ALuint BufferSize;
ALenum Format;
const ALCchar *szDeviceName;
ALCchar *szDeviceName;
// Maximum number of sources that can be created
ALuint MaxNoOfSources;