static int alsa_format_to_oss(snd_pcm_format_t format)
{
- switch (snd_enum_to_int(format)) {
+ switch (format) {
case SND_PCM_FORMAT_MU_LAW: return AFMT_MU_LAW;
case SND_PCM_FORMAT_A_LAW: return AFMT_A_LAW;
case SND_PCM_FORMAT_IMA_ADPCM: return AFMT_IMA_ADPCM;
pcm_mode = SND_PCM_NONBLOCK;
switch (oflag & O_ACCMODE) {
case O_RDONLY:
- streams = 1 << snd_enum_to_int(SND_PCM_STREAM_CAPTURE);
+ streams = 1 << SND_PCM_STREAM_CAPTURE;
break;
case O_WRONLY:
- streams = 1 << snd_enum_to_int(SND_PCM_STREAM_PLAYBACK);
+ streams = 1 << SND_PCM_STREAM_PLAYBACK;
break;
case O_RDWR:
- streams = ((1 << snd_enum_to_int(SND_PCM_STREAM_PLAYBACK)) |
- (1 << snd_enum_to_int(SND_PCM_STREAM_CAPTURE)));
+ streams = ((1 << SND_PCM_STREAM_PLAYBACK) |
+ (1 << SND_PCM_STREAM_CAPTURE));
break;
default:
errno = EINVAL;
for (k = 0; k < 2; ++k) {
if (!(streams & (1 << k)))
continue;
- result = snd_pcm_open(&dsp->streams[k].pcm, name, snd_int_to_enum(k), pcm_mode);
+ result = snd_pcm_open(&dsp->streams[k].pcm, name, k, pcm_mode);
if (result < 0)
goto _error;
}
{
ssize_t result;
oss_dsp_t *dsp = fds[fd]->private;
- oss_dsp_stream_t *str = &dsp->streams[snd_enum_to_int(SND_PCM_STREAM_PLAYBACK)];
+ oss_dsp_stream_t *str = &dsp->streams[SND_PCM_STREAM_PLAYBACK];
snd_pcm_t *pcm = str->pcm;
snd_pcm_uframes_t frames;
if (!pcm) {
{
ssize_t result;
oss_dsp_t *dsp = fds[fd]->private;
- oss_dsp_stream_t *str = &dsp->streams[snd_enum_to_int(SND_PCM_STREAM_CAPTURE)];
+ oss_dsp_stream_t *str = &dsp->streams[SND_PCM_STREAM_CAPTURE];
snd_pcm_t *pcm = str->pcm;
snd_pcm_uframes_t frames;
if (!pcm) {
*(int *) arg = dsp->oss_format;
break;
case SNDCTL_DSP_GETBLKSIZE:
- str = &dsp->streams[snd_enum_to_int(SND_PCM_STREAM_PLAYBACK)];
+ str = &dsp->streams[SND_PCM_STREAM_PLAYBACK];
if (!str->pcm)
- str = &dsp->streams[snd_enum_to_int(SND_PCM_STREAM_CAPTURE)];
+ str = &dsp->streams[SND_PCM_STREAM_CAPTURE];
pcm = str->pcm;
*(int *) arg = str->period_size * str->frame_bytes;
DEBUG("SNDCTL_DSP_GETBLKSIZE, %p) -> [%d]\n", arg, *(int *)arg);
case SNDCTL_DSP_GETCAPS:
{
result = DSP_CAP_REALTIME | DSP_CAP_TRIGGER | DSP_CAP_MMAP;
- if (dsp->streams[snd_enum_to_int(SND_PCM_STREAM_PLAYBACK)].pcm &&
- dsp->streams[snd_enum_to_int(SND_PCM_STREAM_CAPTURE)].pcm)
+ if (dsp->streams[SND_PCM_STREAM_PLAYBACK].pcm &&
+ dsp->streams[SND_PCM_STREAM_CAPTURE].pcm)
result |= DSP_CAP_DUPLEX;
*(int*)arg = result;
DEBUG("SNDCTL_DSP_GETCAPS, %p) -> [%d]\n", arg, *(int*)arg);
case SNDCTL_DSP_GETTRIGGER:
{
int s = 0;
- pcm = dsp->streams[snd_enum_to_int(SND_PCM_STREAM_PLAYBACK)].pcm;
+ pcm = dsp->streams[SND_PCM_STREAM_PLAYBACK].pcm;
if (pcm) {
if (snd_pcm_state(pcm) == SND_PCM_STATE_RUNNING)
s |= PCM_ENABLE_OUTPUT;
}
- pcm = dsp->streams[snd_enum_to_int(SND_PCM_STREAM_CAPTURE)].pcm;
+ pcm = dsp->streams[SND_PCM_STREAM_CAPTURE].pcm;
if (pcm) {
if (snd_pcm_state(pcm) == SND_PCM_STATE_RUNNING)
s |= PCM_ENABLE_INPUT;
{
DEBUG("SNDCTL_DSP_SETTRIGGER, %p[%d])\n", arg, *(int*)arg);
result = *(int*) arg;
- str = &dsp->streams[snd_enum_to_int(SND_PCM_STREAM_CAPTURE)];
+ str = &dsp->streams[SND_PCM_STREAM_CAPTURE];
pcm = str->pcm;
if (pcm) {
if (result & PCM_ENABLE_INPUT) {
}
}
}
- str = &dsp->streams[snd_enum_to_int(SND_PCM_STREAM_PLAYBACK)];
+ str = &dsp->streams[SND_PCM_STREAM_PLAYBACK];
pcm = str->pcm;
if (pcm) {
if (result & PCM_ENABLE_OUTPUT) {
snd_pcm_sframes_t avail, delay;
snd_pcm_state_t state;
audio_buf_info *info = arg;
- str = &dsp->streams[snd_enum_to_int(SND_PCM_STREAM_CAPTURE)];
+ str = &dsp->streams[SND_PCM_STREAM_CAPTURE];
pcm = str->pcm;
if (!pcm) {
err = -EINVAL;
snd_pcm_sframes_t avail, delay;
snd_pcm_state_t state;
audio_buf_info *info = arg;
- str = &dsp->streams[snd_enum_to_int(SND_PCM_STREAM_PLAYBACK)];
+ str = &dsp->streams[SND_PCM_STREAM_PLAYBACK];
pcm = str->pcm;
if (!pcm) {
err = -EINVAL;
snd_pcm_uframes_t hw_ptr;
snd_pcm_state_t state;
count_info *info = arg;
- str = &dsp->streams[snd_enum_to_int(SND_PCM_STREAM_CAPTURE)];
+ str = &dsp->streams[SND_PCM_STREAM_CAPTURE];
pcm = str->pcm;
if (!pcm) {
err = -EINVAL;
snd_pcm_uframes_t hw_ptr;
snd_pcm_state_t state;
count_info *info = arg;
- str = &dsp->streams[snd_enum_to_int(SND_PCM_STREAM_PLAYBACK)];
+ str = &dsp->streams[SND_PCM_STREAM_PLAYBACK];
pcm = str->pcm;
if (!pcm) {
err = -EINVAL;
{
snd_pcm_sframes_t delay = 0;
snd_pcm_state_t state;
- str = &dsp->streams[snd_enum_to_int(SND_PCM_STREAM_PLAYBACK)];
+ str = &dsp->streams[SND_PCM_STREAM_PLAYBACK];
pcm = str->pcm;
if (!pcm) {
err = -EINVAL;
oss_dsp_stream_t *str;
switch (prot & (PROT_READ | PROT_WRITE)) {
case PROT_READ:
- str = &dsp->streams[snd_enum_to_int(SND_PCM_STREAM_CAPTURE)];
+ str = &dsp->streams[SND_PCM_STREAM_CAPTURE];
break;
case PROT_WRITE:
- str = &dsp->streams[snd_enum_to_int(SND_PCM_STREAM_PLAYBACK)];
+ str = &dsp->streams[SND_PCM_STREAM_PLAYBACK];
break;
case PROT_READ | PROT_WRITE:
- str = &dsp->streams[snd_enum_to_int(SND_PCM_STREAM_PLAYBACK)];
+ str = &dsp->streams[SND_PCM_STREAM_PLAYBACK];
if (!str->pcm)
- str = &dsp->streams[snd_enum_to_int(SND_PCM_STREAM_CAPTURE)];
+ str = &dsp->streams[SND_PCM_STREAM_CAPTURE];
break;
default:
errno = EINVAL;
oss_dsp_t *dsp = fds[fd]->private;
oss_dsp_stream_t *str;
DEBUG("munmap(%p, %lu)\n", addr, (unsigned long)len);
- str = &dsp->streams[snd_enum_to_int(SND_PCM_STREAM_PLAYBACK)];
+ str = &dsp->streams[SND_PCM_STREAM_PLAYBACK];
if (!str->pcm)
- str = &dsp->streams[snd_enum_to_int(SND_PCM_STREAM_CAPTURE)];
+ str = &dsp->streams[SND_PCM_STREAM_CAPTURE];
assert(str->mmap_buffer);
free(str->mmap_buffer);
str->mmap_buffer = 0;