Minor cleanups for OSS and Solaris
This commit is contained in:
parent
e88f954cbf
commit
f5435aa2de
@ -49,6 +49,9 @@
|
|||||||
|
|
||||||
static const ALCchar oss_device[] = "OSS Default";
|
static const ALCchar oss_device[] = "OSS Default";
|
||||||
|
|
||||||
|
static const char *oss_driver = "/dev/dsp";
|
||||||
|
static const char *oss_capture = "/dev/dsp";
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int fd;
|
int fd;
|
||||||
volatile int killNow;
|
volatile int killNow;
|
||||||
@ -149,11 +152,8 @@ static ALuint OSSCaptureProc(ALvoid *ptr)
|
|||||||
|
|
||||||
static ALCenum oss_open_playback(ALCdevice *device, const ALCchar *deviceName)
|
static ALCenum oss_open_playback(ALCdevice *device, const ALCchar *deviceName)
|
||||||
{
|
{
|
||||||
char driver[64];
|
|
||||||
oss_data *data;
|
oss_data *data;
|
||||||
|
|
||||||
strncpy(driver, GetConfigValue("oss", "device", "/dev/dsp"), sizeof(driver)-1);
|
|
||||||
driver[sizeof(driver)-1] = 0;
|
|
||||||
if(!deviceName)
|
if(!deviceName)
|
||||||
deviceName = oss_device;
|
deviceName = oss_device;
|
||||||
else if(strcmp(deviceName, oss_device) != 0)
|
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 = (oss_data*)calloc(1, sizeof(oss_data));
|
||||||
data->killNow = 0;
|
data->killNow = 0;
|
||||||
|
|
||||||
data->fd = open(driver, O_WRONLY);
|
data->fd = open(oss_driver, O_WRONLY);
|
||||||
if(data->fd == -1)
|
if(data->fd == -1)
|
||||||
{
|
{
|
||||||
free(data);
|
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;
|
return ALC_INVALID_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -312,15 +312,11 @@ static ALCenum oss_open_capture(ALCdevice *device, const ALCchar *deviceName)
|
|||||||
audio_buf_info info;
|
audio_buf_info info;
|
||||||
ALuint frameSize;
|
ALuint frameSize;
|
||||||
int numChannels;
|
int numChannels;
|
||||||
char driver[64];
|
|
||||||
oss_data *data;
|
oss_data *data;
|
||||||
int ossFormat;
|
int ossFormat;
|
||||||
int ossSpeed;
|
int ossSpeed;
|
||||||
char *err;
|
char *err;
|
||||||
|
|
||||||
strncpy(driver, GetConfigValue("oss", "capture", "/dev/dsp"), sizeof(driver)-1);
|
|
||||||
driver[sizeof(driver)-1] = 0;
|
|
||||||
|
|
||||||
if(!deviceName)
|
if(!deviceName)
|
||||||
deviceName = oss_device;
|
deviceName = oss_device;
|
||||||
else if(strcmp(deviceName, oss_device) != 0)
|
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 = (oss_data*)calloc(1, sizeof(oss_data));
|
||||||
data->killNow = 0;
|
data->killNow = 0;
|
||||||
|
|
||||||
data->fd = open(driver, O_RDONLY);
|
data->fd = open(oss_capture, O_RDONLY);
|
||||||
if(data->fd == -1)
|
if(data->fd == -1)
|
||||||
{
|
{
|
||||||
free(data);
|
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;
|
return ALC_INVALID_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -353,7 +349,7 @@ static ALCenum oss_open_capture(ALCdevice *device, const ALCchar *deviceName)
|
|||||||
case DevFmtUInt:
|
case DevFmtUInt:
|
||||||
case DevFmtFloat:
|
case DevFmtFloat:
|
||||||
free(data);
|
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;
|
return ALC_INVALID_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -488,6 +484,9 @@ static const BackendFuncs oss_funcs = {
|
|||||||
|
|
||||||
ALCboolean alc_oss_init(BackendFuncs *func_list)
|
ALCboolean alc_oss_init(BackendFuncs *func_list)
|
||||||
{
|
{
|
||||||
|
ConfigValueStr("oss", "device", &oss_driver);
|
||||||
|
ConfigValueStr("oss", "capture", &oss_capture);
|
||||||
|
|
||||||
*func_list = oss_funcs;
|
*func_list = oss_funcs;
|
||||||
return ALC_TRUE;
|
return ALC_TRUE;
|
||||||
}
|
}
|
||||||
@ -504,7 +503,7 @@ void alc_oss_probe(enum DevProbe type)
|
|||||||
{
|
{
|
||||||
#ifdef HAVE_STAT
|
#ifdef HAVE_STAT
|
||||||
struct stat buf;
|
struct stat buf;
|
||||||
if(stat(GetConfigValue("oss", "device", "/dev/dsp"), &buf) == 0)
|
if(stat(oss_device, &buf) == 0)
|
||||||
#endif
|
#endif
|
||||||
AppendAllDeviceList(oss_device);
|
AppendAllDeviceList(oss_device);
|
||||||
}
|
}
|
||||||
@ -514,7 +513,7 @@ void alc_oss_probe(enum DevProbe type)
|
|||||||
{
|
{
|
||||||
#ifdef HAVE_STAT
|
#ifdef HAVE_STAT
|
||||||
struct stat buf;
|
struct stat buf;
|
||||||
if(stat(GetConfigValue("oss", "capture", "/dev/dsp"), &buf) == 0)
|
if(stat(oss_capture, &buf) == 0)
|
||||||
#endif
|
#endif
|
||||||
AppendCaptureDeviceList(oss_device);
|
AppendCaptureDeviceList(oss_device);
|
||||||
}
|
}
|
||||||
|
@ -39,6 +39,8 @@
|
|||||||
|
|
||||||
static const ALCchar solaris_device[] = "Solaris Default";
|
static const ALCchar solaris_device[] = "Solaris Default";
|
||||||
|
|
||||||
|
static const char *solaris_driver = "/dev/audio";
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int fd;
|
int fd;
|
||||||
volatile int killNow;
|
volatile int killNow;
|
||||||
@ -93,12 +95,8 @@ static ALuint SolarisProc(ALvoid *ptr)
|
|||||||
|
|
||||||
static ALCenum solaris_open_playback(ALCdevice *device, const ALCchar *deviceName)
|
static ALCenum solaris_open_playback(ALCdevice *device, const ALCchar *deviceName)
|
||||||
{
|
{
|
||||||
char driver[64];
|
|
||||||
solaris_data *data;
|
solaris_data *data;
|
||||||
|
|
||||||
strncpy(driver, GetConfigValue("solaris", "device", "/dev/audio"), sizeof(driver)-1);
|
|
||||||
driver[sizeof(driver)-1] = 0;
|
|
||||||
|
|
||||||
if(!deviceName)
|
if(!deviceName)
|
||||||
deviceName = solaris_device;
|
deviceName = solaris_device;
|
||||||
else if(strcmp(deviceName, solaris_device) != 0)
|
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 = (solaris_data*)calloc(1, sizeof(solaris_data));
|
||||||
data->killNow = 0;
|
data->killNow = 0;
|
||||||
|
|
||||||
data->fd = open(driver, O_WRONLY);
|
data->fd = open(solaris_driver, O_WRONLY);
|
||||||
if(data->fd == -1)
|
if(data->fd == -1)
|
||||||
{
|
{
|
||||||
free(data);
|
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;
|
return ALC_INVALID_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -182,17 +180,13 @@ static ALCboolean solaris_reset_playback(ALCdevice *device)
|
|||||||
return ALC_FALSE;
|
return ALC_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!((info.play.precision == 8 && info.play.encoding == AUDIO_ENCODING_LINEAR &&
|
if(!((info.play.precision == 8 && info.play.encoding == AUDIO_ENCODING_LINEAR8 && device->FmtType == DevFmtUByte) ||
|
||||||
device->FmtType == DevFmtByte) ||
|
(info.play.precision == 8 && info.play.encoding == AUDIO_ENCODING_LINEAR && device->FmtType == DevFmtByte) ||
|
||||||
(info.play.precision == 8 && info.play.encoding == AUDIO_ENCODING_LINEAR8 &&
|
(info.play.precision == 16 && info.play.encoding == AUDIO_ENCODING_LINEAR && device->FmtType == DevFmtShort) ||
|
||||||
device->FmtType == DevFmtUByte) ||
|
(info.play.precision == 32 && info.play.encoding == AUDIO_ENCODING_LINEAR && device->FmtType == DevFmtInt)))
|
||||||
(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",
|
ERR("Could not set %s samples, got %d (0x%x)\n", DevFmtTypeString(device->FmtType),
|
||||||
device->FmtType, info.play.precision, info.play.encoding);
|
info.play.precision, info.play.encoding);
|
||||||
return ALC_FALSE;
|
return ALC_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -250,6 +244,8 @@ static const BackendFuncs solaris_funcs = {
|
|||||||
|
|
||||||
ALCboolean alc_solaris_init(BackendFuncs *func_list)
|
ALCboolean alc_solaris_init(BackendFuncs *func_list)
|
||||||
{
|
{
|
||||||
|
ConfigValueStr("solaris", "device", &solaris_driver);
|
||||||
|
|
||||||
*func_list = solaris_funcs;
|
*func_list = solaris_funcs;
|
||||||
return ALC_TRUE;
|
return ALC_TRUE;
|
||||||
}
|
}
|
||||||
@ -260,17 +256,18 @@ void alc_solaris_deinit(void)
|
|||||||
|
|
||||||
void alc_solaris_probe(enum DevProbe type)
|
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)
|
switch(type)
|
||||||
{
|
{
|
||||||
case ALL_DEVICE_PROBE:
|
case ALL_DEVICE_PROBE:
|
||||||
|
{
|
||||||
|
#ifdef HAVE_STAT
|
||||||
|
struct stat buf;
|
||||||
|
if(stat(solaris_driver, &buf) == 0)
|
||||||
|
#endif
|
||||||
AppendAllDeviceList(solaris_device);
|
AppendAllDeviceList(solaris_device);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CAPTURE_DEVICE_PROBE:
|
case CAPTURE_DEVICE_PROBE:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user