diff options
Diffstat (limited to 'Alc')
-rw-r--r-- | Alc/alsa.c | 18 | ||||
-rw-r--r-- | Alc/dsound.c | 12 | ||||
-rw-r--r-- | Alc/oss.c | 26 | ||||
-rw-r--r-- | Alc/portaudio.c | 11 | ||||
-rw-r--r-- | Alc/pulseaudio.c | 34 | ||||
-rw-r--r-- | Alc/solaris.c | 13 | ||||
-rw-r--r-- | Alc/wave.c | 13 |
7 files changed, 60 insertions, 67 deletions
@@ -352,7 +352,6 @@ 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; @@ -362,7 +361,9 @@ static ALCboolean alsa_open_playback(ALCdevice *device, const ALCchar *deviceNam strncpy(driver, GetConfigValue("alsa", "device", "default"), sizeof(driver)-1); driver[sizeof(driver)-1] = 0; - if(deviceName) + if(!deviceName) + deviceName = alsaDevice; + else if(strcmp(deviceName, alsaDevice) != 0) { size_t idx; @@ -371,14 +372,11 @@ static ALCboolean alsa_open_playback(ALCdevice *device, const ALCchar *deviceNam if(allDevNameMap[idx].name && strcmp(deviceName, allDevNameMap[idx].name) == 0) { - 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) - goto open_alsa; return ALC_FALSE; } @@ -404,7 +402,7 @@ open_alsa: return ALC_FALSE; } - device->szDeviceName = strdup(devName); + device->szDeviceName = strdup(deviceName); device->ExtraData = data; return ALC_TRUE; } @@ -593,7 +591,9 @@ static ALCboolean alsa_open_capture(ALCdevice *pDevice, const ALCchar *deviceNam strncpy(driver, GetConfigValue("alsa", "capture", "default"), sizeof(driver)-1); driver[sizeof(driver)-1] = 0; - if(deviceName) + if(!deviceName) + deviceName = allCaptureDevNameMap[0].name; + else { size_t idx; @@ -610,8 +610,6 @@ static ALCboolean alsa_open_capture(ALCdevice *pDevice, const ALCchar *deviceNam } return ALC_FALSE; } - else - devName = allCaptureDevNameMap[0].name; open_alsa: data = (alsa_data*)calloc(1, sizeof(alsa_data)); @@ -728,7 +726,7 @@ open_alsa: return ALC_FALSE; } - pDevice->szDeviceName = strdup(devName); + pDevice->szDeviceName = strdup(deviceName); return ALC_TRUE; } diff --git a/Alc/dsound.c b/Alc/dsound.c index bbd9bf0b..5ac1e530 100644 --- a/Alc/dsound.c +++ b/Alc/dsound.c @@ -153,21 +153,21 @@ static ALuint DSoundProc(ALvoid *ptr) static ALCboolean DSoundOpenPlayback(ALCdevice *device, const ALCchar *deviceName) { DSoundData *pData = NULL; - const char *devName; LPGUID guid = NULL; HRESULT hr; if(ds_handle == NULL) return ALC_FALSE; - if(deviceName && strcmp(deviceName, dsDevice) != 0) + if(!deviceName) + deviceName = dsDevice; + else if(strcmp(deviceName, dsDevice) != 0) { ALuint i; for(i = 0;i < NumDevices;i++) { if(strcmp(deviceName, DeviceList[i].name) == 0) { - devName = DeviceList[i].name; guid = &DeviceList[i].guid; break; } @@ -175,8 +175,6 @@ static ALCboolean DSoundOpenPlayback(ALCdevice *device, const ALCchar *deviceNam if(i == NumDevices) return ALC_FALSE; } - else - devName = dsDevice; //Initialise requested device @@ -199,7 +197,7 @@ static ALCboolean DSoundOpenPlayback(ALCdevice *device, const ALCchar *deviceNam return ALC_FALSE; } - device->szDeviceName = strdup(devName); + device->szDeviceName = strdup(deviceName); device->ExtraData = pData; return ALC_TRUE; } @@ -535,7 +533,7 @@ void alcDSoundProbe(int type) return; if(type == DEVICE_PROBE) - AppendDeviceList(DeviceList[0].name); + AppendDeviceList(dsDevice); else if(type == ALL_DEVICE_PROBE) { for(i = 0;i < NumDevices;++i) @@ -147,18 +147,15 @@ 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; strncpy(driver, GetConfigValue("oss", "device", "/dev/dsp"), sizeof(driver)-1); driver[sizeof(driver)-1] = 0; - if(deviceName) - { - if(strcmp(deviceName, oss_device)) - return ALC_FALSE; - devName = oss_device; - } + if(!deviceName) + deviceName = oss_device; + else if(strcmp(deviceName, oss_device) != 0) + return ALC_FALSE; data = (oss_data*)calloc(1, sizeof(oss_data)); data->killNow = 0; @@ -171,7 +168,7 @@ static ALCboolean oss_open_playback(ALCdevice *device, const ALCchar *deviceName return ALC_FALSE; } - device->szDeviceName = strdup(devName); + device->szDeviceName = strdup(deviceName); device->ExtraData = data; return ALC_TRUE; } @@ -299,7 +296,6 @@ 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; @@ -315,12 +311,10 @@ static ALCboolean oss_open_capture(ALCdevice *device, const ALCchar *deviceName) strncpy(driver, GetConfigValue("oss", "capture", "/dev/dsp"), sizeof(driver)-1); driver[sizeof(driver)-1] = 0; - if(deviceName) - { - if(strcmp(deviceName, oss_device_capture)) - return ALC_FALSE; - devName = oss_device_capture; - } + if(!deviceName) + deviceName = oss_device_capture; + else if(strcmp(deviceName, oss_device_capture) != 0) + return ALC_FALSE; data = (oss_data*)calloc(1, sizeof(oss_data)); data->killNow = 0; @@ -410,7 +404,7 @@ static ALCboolean oss_open_capture(ALCdevice *device, const ALCchar *deviceName) return ALC_FALSE; } - device->szDeviceName = strdup(devName); + device->szDeviceName = strdup(deviceName); return ALC_TRUE; } diff --git a/Alc/portaudio.c b/Alc/portaudio.c index a8a8ceb5..0142cac3 100644 --- a/Alc/portaudio.c +++ b/Alc/portaudio.c @@ -83,11 +83,10 @@ static ALCboolean pa_open_playback(ALCdevice *device, const ALCchar *deviceName) if(pa_handle == NULL) return ALC_FALSE; - if(deviceName) - { - if(strcmp(deviceName, pa_device) != 0) - return ALC_FALSE; - } + if(!deviceName) + deviceName = pa_device; + else if(strcmp(deviceName, pa_device) != 0) + return ALC_FALSE; data = (pa_data*)calloc(1, sizeof(pa_data)); device->ExtraData = data; @@ -141,7 +140,7 @@ static ALCboolean pa_open_playback(ALCdevice *device, const ALCchar *deviceName) return ALC_FALSE; } - device->szDeviceName = strdup(pa_device); + device->szDeviceName = strdup(deviceName); device->UpdateSize = device->BufferSize/periods; return ALC_TRUE; } diff --git a/Alc/pulseaudio.c b/Alc/pulseaudio.c index 8275033b..3b358a01 100644 --- a/Alc/pulseaudio.c +++ b/Alc/pulseaudio.c @@ -325,13 +325,12 @@ static ALCboolean pulse_open_playback(ALCdevice *device, const ALCchar *device_n if(!pa_handle) return ALC_FALSE; - if(device_name) - { - if(strcmp(device_name, pulse_device) != 0) - return ALC_FALSE; - } + if(!device_name) + device_name = pulse_device; + else if(strcmp(device_name, pulse_device) != 0) + return ALC_FALSE; - return pulse_open(device, pulse_device); + return pulse_open(device, device_name); } //}}} static void pulse_close_playback(ALCdevice *device) //{{{ @@ -458,13 +457,12 @@ static ALCboolean pulse_open_capture(ALCdevice *device, const ALCchar *device_na if(!pa_handle) return ALC_FALSE; - if(device_name) - { - if(strcmp(device_name, pulse_capture_device) != 0) - return ALC_FALSE; - } + if(!device_name) + device_name = pulse_capture_device; + else if(strcmp(device_name, pulse_capture_device) != 0) + return ALC_FALSE; - if(pulse_open(device, pulse_capture_device) == ALC_FALSE) + if(pulse_open(device, device_name) == ALC_FALSE) return ALC_FALSE; data = device->ExtraData; @@ -478,6 +476,8 @@ static ALCboolean pulse_open_capture(ALCdevice *device, const ALCchar *device_na { ppa_threaded_mainloop_unlock(data->loop); pulse_close(device); + free(device->szDeviceName); + device->szDeviceName = NULL; return ALC_FALSE; } @@ -503,6 +503,8 @@ static ALCboolean pulse_open_capture(ALCdevice *device, const ALCchar *device_na AL_PRINT("Unknown format: %x\n", device->Format); ppa_threaded_mainloop_unlock(data->loop); pulse_close(device); + free(device->szDeviceName); + device->szDeviceName = NULL; return ALC_FALSE; } @@ -511,6 +513,8 @@ static ALCboolean pulse_open_capture(ALCdevice *device, const ALCchar *device_na AL_PRINT("Invalid sample format\n"); ppa_threaded_mainloop_unlock(data->loop); pulse_close(device); + free(device->szDeviceName); + device->szDeviceName = NULL; return ALC_FALSE; } @@ -522,6 +526,8 @@ static ALCboolean pulse_open_capture(ALCdevice *device, const ALCchar *device_na ppa_threaded_mainloop_unlock(data->loop); pulse_close(device); + free(device->szDeviceName); + device->szDeviceName = NULL; return ALC_FALSE; } @@ -537,6 +543,8 @@ static ALCboolean pulse_open_capture(ALCdevice *device, const ALCchar *device_na data->stream = NULL; pulse_close(device); + free(device->szDeviceName); + device->szDeviceName = NULL; return ALC_FALSE; } @@ -552,6 +560,8 @@ static ALCboolean pulse_open_capture(ALCdevice *device, const ALCchar *device_na data->stream = NULL; pulse_close(device); + free(device->szDeviceName); + device->szDeviceName = NULL; return ALC_FALSE; } diff --git a/Alc/solaris.c b/Alc/solaris.c index e6421c2d..b5659608 100644 --- a/Alc/solaris.c +++ b/Alc/solaris.c @@ -92,7 +92,6 @@ 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]; @@ -101,12 +100,10 @@ static ALCboolean solaris_open_playback(ALCdevice *device, const ALCchar *device strncpy(driver, GetConfigValue("solaris", "device", "/dev/audio"), sizeof(driver)-1); driver[sizeof(driver)-1] = 0; - if(deviceName) - { - if(strcmp(deviceName, solaris_device)) - return ALC_FALSE; - devName = solaris_device; - } + if(!deviceName) + deviceName = solaris_device; + else if(strcmp(deviceName, solaris_device) != 0) + return ALC_FALSE; data = (solaris_data*)calloc(1, sizeof(solaris_data)); data->killNow = 0; @@ -193,7 +190,7 @@ static ALCboolean solaris_open_playback(ALCdevice *device, const ALCchar *device return ALC_FALSE; } - device->szDeviceName = strdup(devName); + device->szDeviceName = strdup(deviceName); return ALC_TRUE; } @@ -108,7 +108,6 @@ 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; @@ -116,12 +115,10 @@ static ALCboolean wave_open_playback(ALCdevice *device, const ALCchar *deviceNam if(!fname[0]) return ALC_FALSE; - if(deviceName) - { - if(strcmp(deviceName, waveDevice) != 0) - return ALC_FALSE; - devName = waveDevice; - } + if(!deviceName) + deviceName = waveDevice; + else if(strcmp(deviceName, waveDevice) != 0) + return ALC_FALSE; data = (wave_data*)calloc(1, sizeof(wave_data)); @@ -133,7 +130,7 @@ static ALCboolean wave_open_playback(ALCdevice *device, const ALCchar *deviceNam return ALC_FALSE; } - device->szDeviceName = strdup(devName); + device->szDeviceName = strdup(deviceName); device->ExtraData = data; return ALC_TRUE; } |