From 54cdd494944b1291bf3fa1e3ac45fe8229526ff0 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Fri, 10 Aug 2001 10:12:02 +0000 Subject: [PATCH] - Removed snd_enum_to_int and snd_int_to_enum. - Added ALSA version check in configure script. --- Makefile.am | 3 --- alsa-oss.c | 54 ++++++++++++++++++++++++++-------------------------- configure.in | 1 + 3 files changed, 28 insertions(+), 30 deletions(-) diff --git a/Makefile.am b/Makefile.am index 782e321..9dafc41 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,6 +1,3 @@ - -CFLAGS = -g -O2 -W -Wall - lib_LTLIBRARIES = libaoss.la libaoss_la_SOURCES = alsa-oss.c diff --git a/alsa-oss.c b/alsa-oss.c index 0a3bfe7..886cb74 100644 --- a/alsa-oss.c +++ b/alsa-oss.c @@ -176,7 +176,7 @@ static snd_pcm_format_t oss_format_to_alsa(int format) 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; @@ -405,14 +405,14 @@ static int oss_dsp_open(int card, int device, int oflag, mode_t mode) 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; @@ -434,7 +434,7 @@ static int oss_dsp_open(int card, int device, int oflag, mode_t mode) 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; } @@ -643,7 +643,7 @@ static ssize_t oss_dsp_write(int fd, const void *buf, size_t n) { 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) { @@ -678,7 +678,7 @@ static ssize_t oss_dsp_read(int fd, void *buf, size_t n) { 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) { @@ -849,9 +849,9 @@ static int oss_dsp_ioctl(int fd, unsigned long cmd, ...) *(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); @@ -905,8 +905,8 @@ static int oss_dsp_ioctl(int fd, unsigned long cmd, ...) 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); @@ -915,12 +915,12 @@ static int oss_dsp_ioctl(int fd, unsigned long cmd, ...) 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; @@ -933,7 +933,7 @@ static int oss_dsp_ioctl(int fd, unsigned long cmd, ...) { 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) { @@ -961,7 +961,7 @@ static int oss_dsp_ioctl(int fd, unsigned long cmd, ...) } } } - 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) { @@ -1006,7 +1006,7 @@ static int oss_dsp_ioctl(int fd, unsigned long cmd, ...) 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; @@ -1037,7 +1037,7 @@ static int oss_dsp_ioctl(int fd, unsigned long cmd, ...) 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; @@ -1070,7 +1070,7 @@ static int oss_dsp_ioctl(int fd, unsigned long cmd, ...) 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; @@ -1108,7 +1108,7 @@ static int oss_dsp_ioctl(int fd, unsigned long cmd, ...) 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; @@ -1145,7 +1145,7 @@ static int oss_dsp_ioctl(int fd, unsigned long cmd, ...) { 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; @@ -1270,15 +1270,15 @@ static void *oss_dsp_mmap(void *addr ATTRIBUTE_UNUSED, size_t len ATTRIBUTE_UNUS 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; @@ -1318,9 +1318,9 @@ static int oss_dsp_munmap(int fd, void *addr ATTRIBUTE_UNUSED, size_t len ATTRIB 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; diff --git a/configure.in b/configure.in index 6b18c1e..d97ef6d 100644 --- a/configure.in +++ b/configure.in @@ -5,5 +5,6 @@ AC_PROG_CC AC_PROG_INSTALL AC_PROG_LN_S AM_PROG_LIBTOOL +AM_PATH_ALSA(0.9.0) AC_OUTPUT(Makefile) -- 2.47.1