oss: added OssData.audio_format
This replaces the separate properties channels, sampleRate, bits.
This commit is contained in:
parent
96155a3376
commit
8fc6b93afc
@ -45,10 +45,8 @@
|
|||||||
typedef struct _OssData {
|
typedef struct _OssData {
|
||||||
int fd;
|
int fd;
|
||||||
const char *device;
|
const char *device;
|
||||||
int channels;
|
struct audio_format audio_format;
|
||||||
int sampleRate;
|
|
||||||
int bitFormat;
|
int bitFormat;
|
||||||
int bits;
|
|
||||||
int *supported[3];
|
int *supported[3];
|
||||||
int numSupported[3];
|
int numSupported[3];
|
||||||
int *unsupported[3];
|
int *unsupported[3];
|
||||||
@ -447,19 +445,24 @@ static int oss_open(OssData *od)
|
|||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (setParam(od, SNDCTL_DSP_CHANNELS, &od->channels)) {
|
tmp = od->audio_format.channels;
|
||||||
ERROR("OSS device \"%s\" does not support %i channels: %s\n",
|
if (setParam(od, SNDCTL_DSP_CHANNELS, &tmp)) {
|
||||||
od->device, od->channels, strerror(errno));
|
ERROR("OSS device \"%s\" does not support %u channels: %s\n",
|
||||||
|
od->device, od->audio_format.channels, strerror(errno));
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
od->audio_format.channels = tmp;
|
||||||
|
|
||||||
if (setParam(od, SNDCTL_DSP_SPEED, &od->sampleRate)) {
|
tmp = od->audio_format.sample_rate;
|
||||||
ERROR("OSS device \"%s\" does not support %i Hz audio: %s\n",
|
if (setParam(od, SNDCTL_DSP_SPEED, &tmp)) {
|
||||||
od->device, od->sampleRate, strerror(errno));
|
ERROR("OSS device \"%s\" does not support %u Hz audio: %s\n",
|
||||||
|
od->device, od->audio_format.sample_rate,
|
||||||
|
strerror(errno));
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
od->audio_format.sample_rate = tmp;
|
||||||
|
|
||||||
switch (od->bits) {
|
switch (od->audio_format.bits) {
|
||||||
case 8:
|
case 8:
|
||||||
tmp = AFMT_S8;
|
tmp = AFMT_S8;
|
||||||
break;
|
break;
|
||||||
@ -468,7 +471,7 @@ static int oss_open(OssData *od)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (setParam(od, SNDCTL_DSP_SAMPLESIZE, &tmp)) {
|
if (setParam(od, SNDCTL_DSP_SAMPLESIZE, &tmp)) {
|
||||||
ERROR("OSS device \"%s\" does not support %i bit audio: %s\n",
|
ERROR("OSS device \"%s\" does not support %u bit audio: %s\n",
|
||||||
od->device, tmp, strerror(errno));
|
od->device, tmp, strerror(errno));
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
@ -486,19 +489,17 @@ static int oss_openDevice(void *data,
|
|||||||
int ret;
|
int ret;
|
||||||
OssData *od = data;
|
OssData *od = data;
|
||||||
|
|
||||||
od->channels = (int8_t)audioFormat->channels;
|
od->audio_format = *audioFormat;
|
||||||
od->sampleRate = audioFormat->sample_rate;
|
|
||||||
od->bits = (int8_t)audioFormat->bits;
|
|
||||||
|
|
||||||
if ((ret = oss_open(od)) < 0)
|
if ((ret = oss_open(od)) < 0)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
audioFormat->channels = od->channels;
|
*audioFormat = od->audio_format;
|
||||||
audioFormat->sample_rate = od->sampleRate;
|
|
||||||
audioFormat->bits = od->bits;
|
|
||||||
|
|
||||||
DEBUG("oss device \"%s\" will be playing %i bit %i channel audio at "
|
DEBUG("oss device \"%s\" will be playing %u bit %u channel audio at "
|
||||||
"%i Hz\n", od->device, od->bits, od->channels, od->sampleRate);
|
"%u Hz\n", od->device,
|
||||||
|
od->audio_format.bits, od->audio_format.channels,
|
||||||
|
od->audio_format.sample_rate);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user