diff options
Diffstat (limited to 'Alc/backends')
-rw-r--r-- | Alc/backends/oss.c | 27 | ||||
-rw-r--r-- | Alc/backends/solaris.c | 45 |
2 files changed, 34 insertions, 38 deletions
diff --git a/Alc/backends/oss.c b/Alc/backends/oss.c index 21c62d13..bd489e3e 100644 --- a/Alc/backends/oss.c +++ b/Alc/backends/oss.c @@ -49,6 +49,9 @@ static const ALCchar oss_device[] = "OSS Default"; +static const char *oss_driver = "/dev/dsp"; +static const char *oss_capture = "/dev/dsp"; + typedef struct { int fd; volatile int killNow; @@ -149,11 +152,8 @@ static ALuint OSSCaptureProc(ALvoid *ptr) static ALCenum oss_open_playback(ALCdevice *device, const ALCchar *deviceName) { - char driver[64]; oss_data *data; - strncpy(driver, GetConfigValue("oss", "device", "/dev/dsp"), sizeof(driver)-1); - driver[sizeof(driver)-1] = 0; if(!deviceName) deviceName = oss_device; else if(strcmp(deviceName, oss_device) != 0) @@ -162,11 +162,11 @@ static ALCenum oss_open_playback(ALCdevice *device, const ALCchar *deviceName) data = (oss_data*)calloc(1, sizeof(oss_data)); data->killNow = 0; - data->fd = open(driver, O_WRONLY); + data->fd = open(oss_driver, O_WRONLY); if(data->fd == -1) { free(data); - ERR("Could not open %s: %s\n", driver, strerror(errno)); + ERR("Could not open %s: %s\n", oss_driver, strerror(errno)); return ALC_INVALID_VALUE; } @@ -312,15 +312,11 @@ static ALCenum oss_open_capture(ALCdevice *device, const ALCchar *deviceName) audio_buf_info info; ALuint frameSize; int numChannels; - char driver[64]; oss_data *data; int ossFormat; int ossSpeed; char *err; - strncpy(driver, GetConfigValue("oss", "capture", "/dev/dsp"), sizeof(driver)-1); - driver[sizeof(driver)-1] = 0; - if(!deviceName) deviceName = oss_device; else if(strcmp(deviceName, oss_device) != 0) @@ -329,11 +325,11 @@ static ALCenum oss_open_capture(ALCdevice *device, const ALCchar *deviceName) data = (oss_data*)calloc(1, sizeof(oss_data)); data->killNow = 0; - data->fd = open(driver, O_RDONLY); + data->fd = open(oss_capture, O_RDONLY); if(data->fd == -1) { free(data); - ERR("Could not open %s: %s\n", driver, strerror(errno)); + ERR("Could not open %s: %s\n", oss_capture, strerror(errno)); return ALC_INVALID_VALUE; } @@ -353,7 +349,7 @@ static ALCenum oss_open_capture(ALCdevice *device, const ALCchar *deviceName) case DevFmtUInt: case DevFmtFloat: free(data); - ERR("%s capture samples not supported on OSS\n", DevFmtTypeString(device->FmtType)); + ERR("%s capture samples not supported\n", DevFmtTypeString(device->FmtType)); return ALC_INVALID_VALUE; } @@ -488,6 +484,9 @@ static const BackendFuncs oss_funcs = { ALCboolean alc_oss_init(BackendFuncs *func_list) { + ConfigValueStr("oss", "device", &oss_driver); + ConfigValueStr("oss", "capture", &oss_capture); + *func_list = oss_funcs; return ALC_TRUE; } @@ -504,7 +503,7 @@ void alc_oss_probe(enum DevProbe type) { #ifdef HAVE_STAT struct stat buf; - if(stat(GetConfigValue("oss", "device", "/dev/dsp"), &buf) == 0) + if(stat(oss_device, &buf) == 0) #endif AppendAllDeviceList(oss_device); } @@ -514,7 +513,7 @@ void alc_oss_probe(enum DevProbe type) { #ifdef HAVE_STAT struct stat buf; - if(stat(GetConfigValue("oss", "capture", "/dev/dsp"), &buf) == 0) + if(stat(oss_capture, &buf) == 0) #endif AppendCaptureDeviceList(oss_device); } diff --git a/Alc/backends/solaris.c b/Alc/backends/solaris.c index 02a6c9a5..bf0f57f5 100644 --- a/Alc/backends/solaris.c +++ b/Alc/backends/solaris.c @@ -39,6 +39,8 @@ static const ALCchar solaris_device[] = "Solaris Default"; +static const char *solaris_driver = "/dev/audio"; + typedef struct { int fd; volatile int killNow; @@ -93,12 +95,8 @@ static ALuint SolarisProc(ALvoid *ptr) static ALCenum solaris_open_playback(ALCdevice *device, const ALCchar *deviceName) { - char driver[64]; solaris_data *data; - strncpy(driver, GetConfigValue("solaris", "device", "/dev/audio"), sizeof(driver)-1); - driver[sizeof(driver)-1] = 0; - if(!deviceName) deviceName = solaris_device; else if(strcmp(deviceName, solaris_device) != 0) @@ -107,11 +105,11 @@ static ALCenum solaris_open_playback(ALCdevice *device, const ALCchar *deviceNam data = (solaris_data*)calloc(1, sizeof(solaris_data)); data->killNow = 0; - data->fd = open(driver, O_WRONLY); + data->fd = open(solaris_driver, O_WRONLY); if(data->fd == -1) { free(data); - ERR("Could not open %s: %s\n", driver, strerror(errno)); + ERR("Could not open %s: %s\n", solaris_driver, strerror(errno)); return ALC_INVALID_VALUE; } @@ -182,17 +180,13 @@ static ALCboolean solaris_reset_playback(ALCdevice *device) return ALC_FALSE; } - if(!((info.play.precision == 8 && info.play.encoding == AUDIO_ENCODING_LINEAR && - device->FmtType == DevFmtByte) || - (info.play.precision == 8 && info.play.encoding == AUDIO_ENCODING_LINEAR8 && - device->FmtType == DevFmtUByte) || - (info.play.precision == 16 && info.play.encoding == AUDIO_ENCODING_LINEAR && - device->FmtType == DevFmtShort) || - (info.play.precision == 32 && info.play.encoding == AUDIO_ENCODING_LINEAR && - device->FmtType == DevFmtInt))) + if(!((info.play.precision == 8 && info.play.encoding == AUDIO_ENCODING_LINEAR8 && device->FmtType == DevFmtUByte) || + (info.play.precision == 8 && info.play.encoding == AUDIO_ENCODING_LINEAR && device->FmtType == DevFmtByte) || + (info.play.precision == 16 && info.play.encoding == AUDIO_ENCODING_LINEAR && device->FmtType == DevFmtShort) || + (info.play.precision == 32 && info.play.encoding == AUDIO_ENCODING_LINEAR && device->FmtType == DevFmtInt))) { - ERR("Could not set %#x sample type, got %d (%#x)\n", - device->FmtType, info.play.precision, info.play.encoding); + ERR("Could not set %s samples, got %d (0x%x)\n", DevFmtTypeString(device->FmtType), + info.play.precision, info.play.encoding); return ALC_FALSE; } @@ -250,6 +244,8 @@ static const BackendFuncs solaris_funcs = { ALCboolean alc_solaris_init(BackendFuncs *func_list) { + ConfigValueStr("solaris", "device", &solaris_driver); + *func_list = solaris_funcs; return ALC_TRUE; } @@ -260,17 +256,18 @@ void alc_solaris_deinit(void) void alc_solaris_probe(enum DevProbe type) { -#ifdef HAVE_STAT - struct stat buf; - if(stat(GetConfigValue("solaris", "device", "/dev/audio"), &buf) != 0) - return; -#endif - switch(type) { case ALL_DEVICE_PROBE: - AppendAllDeviceList(solaris_device); - break; + { +#ifdef HAVE_STAT + struct stat buf; + if(stat(solaris_driver, &buf) == 0) +#endif + AppendAllDeviceList(solaris_device); + } + break; + case CAPTURE_DEVICE_PROBE: break; } |