aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Alc/ALc.c8
-rw-r--r--Alc/alsa.c15
-rw-r--r--Alc/dsound.c6
-rw-r--r--Alc/oss.c12
-rw-r--r--Alc/portaudio.c3
-rw-r--r--Alc/pulseaudio.c6
-rw-r--r--Alc/solaris.c6
-rw-r--r--Alc/wave.c6
-rw-r--r--Alc/winmm.c3
-rw-r--r--OpenAL32/Include/alMain.h2
10 files changed, 38 insertions, 29 deletions
diff --git a/Alc/ALc.c b/Alc/ALc.c
index 588ba903..f3ff1d85 100644
--- a/Alc/ALc.c
+++ b/Alc/ALc.c
@@ -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);
diff --git a/Alc/alsa.c b/Alc/alsa.c
index 89b8bbae..9c5bf3cd 100644
--- a/Alc/alsa.c
+++ b/Alc/alsa.c
@@ -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;
}
diff --git a/Alc/dsound.c b/Alc/dsound.c
index 644407b8..8f5d3b11 100644
--- a/Alc/dsound.c
+++ b/Alc/dsound.c
@@ -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;
}
diff --git a/Alc/oss.c b/Alc/oss.c
index 5fe67c53..6b476ee4 100644
--- a/Alc/oss.c
+++ b/Alc/oss.c
@@ -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;
}
diff --git a/Alc/portaudio.c b/Alc/portaudio.c
index 6d1b6837..c50214a2 100644
--- a/Alc/portaudio.c
+++ b/Alc/portaudio.c
@@ -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;
}
diff --git a/Alc/pulseaudio.c b/Alc/pulseaudio.c
index 4bce7379..4f39afb5 100644
--- a/Alc/pulseaudio.c
+++ b/Alc/pulseaudio.c
@@ -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;
diff --git a/Alc/solaris.c b/Alc/solaris.c
index 5c7716f6..63f92bf4 100644
--- a/Alc/solaris.c
+++ b/Alc/solaris.c
@@ -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;
}
diff --git a/Alc/wave.c b/Alc/wave.c
index 578b769e..47f43b66 100644
--- a/Alc/wave.c
+++ b/Alc/wave.c
@@ -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;
}
diff --git a/Alc/winmm.c b/Alc/winmm.c
index 3b226f29..1f62f5a1 100644
--- a/Alc/winmm.c
+++ b/Alc/winmm.c
@@ -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;
}
diff --git a/OpenAL32/Include/alMain.h b/OpenAL32/Include/alMain.h
index 4713c704..696eda86 100644
--- a/OpenAL32/Include/alMain.h
+++ b/OpenAL32/Include/alMain.h
@@ -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;