From: Abramo Bagnara Date: Sun, 9 Jan 2000 22:44:52 +0000 (+0000) Subject: uniformed alsa-lib interfaces X-Git-Tag: v1.0.3~1356 X-Git-Url: https://git.alsa-project.org/?a=commitdiff_plain;h=d2911f9f341d7839a5f6aba142a5c2809f2f7efb;p=alsa-lib.git uniformed alsa-lib interfaces --- diff --git a/include/pcm.h b/include/pcm.h index 8fe0a6cc..47dd2e05 100644 --- a/include/pcm.h +++ b/include/pcm.h @@ -34,10 +34,10 @@ int snd_pcm_playback_go(snd_pcm_t *handle); int snd_pcm_capture_go(snd_pcm_t *handle); int snd_pcm_channel_go(snd_pcm_t *handle, int channel); int snd_pcm_sync_go(snd_pcm_t *handle, snd_pcm_sync_t *sync); -int snd_pcm_drain_playback(snd_pcm_t *handle); -int snd_pcm_flush_playback(snd_pcm_t *handle); -int snd_pcm_flush_capture(snd_pcm_t *handle); -int snd_pcm_flush_channel(snd_pcm_t *handle, int channel); +int snd_pcm_playback_drain(snd_pcm_t *handle); +int snd_pcm_playback_flush(snd_pcm_t *handle); +int snd_pcm_capture_flush(snd_pcm_t *handle); +int snd_pcm_channel_flush(snd_pcm_t *handle, int channel); int snd_pcm_playback_pause(snd_pcm_t *handle, int enable); ssize_t snd_pcm_transfer_size(snd_pcm_t *handle, int channel); ssize_t snd_pcm_write(snd_pcm_t *handle, const void *buffer, size_t size); diff --git a/include/rawmidi.h b/include/rawmidi.h index c14d9da6..ccaea8dc 100644 --- a/include/rawmidi.h +++ b/include/rawmidi.h @@ -23,13 +23,12 @@ int snd_rawmidi_close(snd_rawmidi_t *handle); int snd_rawmidi_file_descriptor(snd_rawmidi_t *handle); int snd_rawmidi_block_mode(snd_rawmidi_t *handle, int enable); int snd_rawmidi_info(snd_rawmidi_t *handle, snd_rawmidi_info_t * info); -int snd_rawmidi_output_params(snd_rawmidi_t *handle, snd_rawmidi_output_params_t * params); -int snd_rawmidi_input_params(snd_rawmidi_t *handle, snd_rawmidi_input_params_t * params); -int snd_rawmidi_output_status(snd_rawmidi_t *handle, snd_rawmidi_output_status_t * status); -int snd_rawmidi_input_status(snd_rawmidi_t *handle, snd_rawmidi_input_status_t * status); -int snd_rawmidi_drain_output(snd_rawmidi_t *handle); -int snd_rawmidi_flush_output(snd_rawmidi_t *handle); -int snd_rawmidi_flush_input(snd_rawmidi_t *handle); +int snd_rawmidi_channel_params(snd_rawmidi_t *handle, snd_rawmidi_params_t * params); +int snd_rawmidi_channel_status(snd_rawmidi_t *handle, snd_rawmidi_status_t * status); +int snd_rawmidi_output_drain(snd_rawmidi_t *handle); +int snd_rawmidi_output_flush(snd_rawmidi_t *handle); +int snd_rawmidi_input_flush(snd_rawmidi_t *handle); +int snd_rawmidi_channel_flush(snd_rawmidi_t *handle, int channel); ssize_t snd_rawmidi_write(snd_rawmidi_t *handle, const void *buffer, size_t size); ssize_t snd_rawmidi_read(snd_rawmidi_t *handle, void *buffer, size_t size); diff --git a/src/control/control.c b/src/control/control.c index 67be2e49..74618c3d 100644 --- a/src/control/control.c +++ b/src/control/control.c @@ -353,7 +353,7 @@ int snd_ctl_rawmidi_info(snd_ctl_t *handle, int dev, snd_rawmidi_info_t * info) return 0; } -int snd_ctl_rawmidi_output_switch_list(snd_ctl_t *handle, int dev, snd_switch_list_t *list) +int snd_ctl_rawmidi_channel_switch_list(snd_ctl_t *handle, int dev, int chn, snd_switch_list_t *list) { snd_ctl_t *ctl; @@ -362,12 +362,14 @@ int snd_ctl_rawmidi_output_switch_list(snd_ctl_t *handle, int dev, snd_switch_li return -EINVAL; if (ioctl(ctl->fd, SND_CTL_IOCTL_RAWMIDI_DEVICE, &dev) < 0) return -errno; - if (ioctl(ctl->fd, SND_CTL_IOCTL_RAWMIDI_OSWITCH_LIST, list) < 0) + if (ioctl(ctl->fd, SND_CTL_IOCTL_RAWMIDI_CHANNEL, &chn) < 0) + return -errno; + if (ioctl(ctl->fd, SND_CTL_IOCTL_RAWMIDI_SWITCH_LIST, list) < 0) return -errno; return 0; } -int snd_ctl_rawmidi_output_switch_read(snd_ctl_t *handle, int dev, snd_switch_t * sw) +int snd_ctl_rawmidi_channel_switch_read(snd_ctl_t *handle, int dev, int chn, snd_switch_t * sw) { snd_ctl_t *ctl; @@ -376,12 +378,14 @@ int snd_ctl_rawmidi_output_switch_read(snd_ctl_t *handle, int dev, snd_switch_t return -EINVAL; if (ioctl(ctl->fd, SND_CTL_IOCTL_RAWMIDI_DEVICE, &dev) < 0) return -errno; - if (ioctl(ctl->fd, SND_CTL_IOCTL_RAWMIDI_OSWITCH_READ, sw) < 0) + if (ioctl(ctl->fd, SND_CTL_IOCTL_RAWMIDI_CHANNEL, &chn) < 0) + return -errno; + if (ioctl(ctl->fd, SND_CTL_IOCTL_RAWMIDI_SWITCH_READ, sw) < 0) return -errno; return 0; } -int snd_ctl_rawmidi_output_switch_write(snd_ctl_t *handle, int dev, snd_switch_t * sw) +int snd_ctl_rawmidi_channel_switch_write(snd_ctl_t *handle, int dev, int chn, snd_switch_t * sw) { snd_ctl_t *ctl; @@ -390,51 +394,41 @@ int snd_ctl_rawmidi_output_switch_write(snd_ctl_t *handle, int dev, snd_switch_t return -EINVAL; if (ioctl(ctl->fd, SND_CTL_IOCTL_RAWMIDI_DEVICE, &dev) < 0) return -errno; - if (ioctl(ctl->fd, SND_CTL_IOCTL_RAWMIDI_OSWITCH_WRITE, sw) < 0) + if (ioctl(ctl->fd, SND_CTL_IOCTL_RAWMIDI_CHANNEL, &chn) < 0) + return -errno; + if (ioctl(ctl->fd, SND_CTL_IOCTL_RAWMIDI_SWITCH_WRITE, sw) < 0) return -errno; return 0; } -int snd_ctl_rawmidi_input_switch_list(snd_ctl_t *handle, int dev, snd_switch_list_t *list) +int snd_ctl_rawmidi_output_switch_list(snd_ctl_t *handle, int dev, snd_switch_list_t *list) { - snd_ctl_t *ctl; + return snd_ctl_rawmidi_channel_switch_list(handle, dev, SND_RAWMIDI_CHANNEL_OUTPUT, list); +} - ctl = handle; - if (!ctl || !list || dev < 0) - return -EINVAL; - if (ioctl(ctl->fd, SND_CTL_IOCTL_RAWMIDI_DEVICE, &dev) < 0) - return -errno; - if (ioctl(ctl->fd, SND_CTL_IOCTL_RAWMIDI_ISWITCH_LIST, list) < 0) - return -errno; - return 0; +int snd_ctl_rawmidi_output_switch_read(snd_ctl_t *handle, int dev, snd_switch_t * sw) +{ + return snd_ctl_rawmidi_channel_switch_read(handle, dev, SND_RAWMIDI_CHANNEL_OUTPUT, sw); } -int snd_ctl_rawmidi_input_switch_read(snd_ctl_t *handle, int dev, snd_switch_t * sw) +int snd_ctl_rawmidi_output_switch_write(snd_ctl_t *handle, int dev, snd_switch_t * sw) { - snd_ctl_t *ctl; + return snd_ctl_rawmidi_channel_switch_write(handle, dev, SND_RAWMIDI_CHANNEL_OUTPUT, sw); +} - ctl = handle; - if (!ctl || !sw || dev < 0 || sw->name[0] == '\0') - return -EINVAL; - if (ioctl(ctl->fd, SND_CTL_IOCTL_RAWMIDI_DEVICE, &dev) < 0) - return -errno; - if (ioctl(ctl->fd, SND_CTL_IOCTL_RAWMIDI_ISWITCH_READ, sw) < 0) - return -errno; - return 0; +int snd_ctl_rawmidi_input_switch_list(snd_ctl_t *handle, int dev, snd_switch_list_t *list) +{ + return snd_ctl_rawmidi_channel_switch_list(handle, dev, SND_RAWMIDI_CHANNEL_INPUT, list); } -int snd_ctl_rawmidi_input_switch_write(snd_ctl_t *handle, int dev, snd_switch_t * sw) +int snd_ctl_rawmidi_input_switch_read(snd_ctl_t *handle, int dev, snd_switch_t * sw) { - snd_ctl_t *ctl; + return snd_ctl_rawmidi_channel_switch_read(handle, dev, SND_RAWMIDI_CHANNEL_INPUT, sw); +} - ctl = handle; - if (!ctl || !sw || dev < 0 || sw->name[0] == '\0') - return -EINVAL; - if (ioctl(ctl->fd, SND_CTL_IOCTL_RAWMIDI_DEVICE, &dev) < 0) - return -errno; - if (ioctl(ctl->fd, SND_CTL_IOCTL_RAWMIDI_ISWITCH_WRITE, sw) < 0) - return -errno; - return 0; +int snd_ctl_rawmidi_input_switch_write(snd_ctl_t *handle, int dev, snd_switch_t * sw) +{ + return snd_ctl_rawmidi_channel_switch_write(handle, dev, SND_RAWMIDI_CHANNEL_INPUT, sw); } int snd_control_read(snd_ctl_t *handle, snd_ctl_callbacks_t * callbacks) diff --git a/src/pcm/pcm.c b/src/pcm/pcm.c index 177138e8..ccb5b934 100644 --- a/src/pcm/pcm.c +++ b/src/pcm/pcm.c @@ -363,7 +363,7 @@ int snd_pcm_sync_go(snd_pcm_t *pcm, snd_pcm_sync_t *sync) return 0; } -int snd_pcm_drain_playback(snd_pcm_t *pcm) +int snd_pcm_playback_drain(snd_pcm_t *pcm) { if (!pcm) return -EINVAL; @@ -374,7 +374,7 @@ int snd_pcm_drain_playback(snd_pcm_t *pcm) return 0; } -int snd_pcm_flush_playback(snd_pcm_t *pcm) +int snd_pcm_playback_flush(snd_pcm_t *pcm) { if (!pcm) return -EINVAL; @@ -385,7 +385,7 @@ int snd_pcm_flush_playback(snd_pcm_t *pcm) return 0; } -int snd_pcm_flush_capture(snd_pcm_t *pcm) +int snd_pcm_capture_flush(snd_pcm_t *pcm) { if (!pcm) return -EINVAL; @@ -396,13 +396,13 @@ int snd_pcm_flush_capture(snd_pcm_t *pcm) return 0; } -int snd_pcm_flush_channel(snd_pcm_t *pcm, int channel) +int snd_pcm_channel_flush(snd_pcm_t *pcm, int channel) { switch (channel) { case SND_PCM_CHANNEL_PLAYBACK: - return snd_pcm_flush_playback(pcm); + return snd_pcm_playback_flush(pcm); case SND_PCM_CHANNEL_CAPTURE: - return snd_pcm_flush_capture(pcm); + return snd_pcm_capture_flush(pcm); default: return -EIO; } diff --git a/src/pcm/pcm_plugin.c b/src/pcm/pcm_plugin.c index 717f5ae9..033473bf 100644 --- a/src/pcm/pcm_plugin.c +++ b/src/pcm/pcm_plugin.c @@ -358,7 +358,7 @@ int snd_pcm_plugin_drain_playback(snd_pcm_t *pcm) if ((err = snd_pcm_plugin_action(pcm, SND_PCM_CHANNEL_PLAYBACK, DRAIN))<0) return err; - return snd_pcm_drain_playback(pcm); + return snd_pcm_playback_drain(pcm); } int snd_pcm_plugin_flush(snd_pcm_t *pcm, int channel) @@ -368,7 +368,7 @@ int snd_pcm_plugin_flush(snd_pcm_t *pcm, int channel) pdprintf("flush\n"); if ((err = snd_pcm_plugin_action(pcm, channel, FLUSH))<0) return err; - return snd_pcm_flush_channel(pcm, channel); + return snd_pcm_channel_flush(pcm, channel); } int snd_pcm_plugin_pointer(snd_pcm_t *pcm, int channel, void **ptr, size_t *size) diff --git a/src/rawmidi/rawmidi.c b/src/rawmidi/rawmidi.c index 3625a4b1..e1f1e1ad 100644 --- a/src/rawmidi/rawmidi.c +++ b/src/rawmidi/rawmidi.c @@ -122,67 +122,57 @@ int snd_rawmidi_info(snd_rawmidi_t *rmidi, snd_rawmidi_info_t * info) return 0; } -int snd_rawmidi_output_params(snd_rawmidi_t *rmidi, snd_rawmidi_output_params_t * params) +int snd_rawmidi_channel_params(snd_rawmidi_t *rmidi, snd_rawmidi_params_t * params) { if (!rmidi || !params) return -EINVAL; - if (ioctl(rmidi->fd, SND_RAWMIDI_IOCTL_OUTPUT_PARAMS, params) < 0) - return -errno; - return 0; -} - -int snd_rawmidi_input_params(snd_rawmidi_t *rmidi, snd_rawmidi_input_params_t * params) -{ - if (!rmidi || !params) + if (params->channel < 0 || params->channel > 1) return -EINVAL; - if (ioctl(rmidi->fd, SND_RAWMIDI_IOCTL_INPUT_PARAMS, params) < 0) + if (ioctl(rmidi->fd, SND_RAWMIDI_IOCTL_CHANNEL_PARAMS, params) < 0) return -errno; return 0; } -int snd_rawmidi_output_status(snd_rawmidi_t *rmidi, snd_rawmidi_output_status_t * status) +int snd_rawmidi_output_status(snd_rawmidi_t *rmidi, snd_rawmidi_status_t * status) { if (!rmidi || !status) return -EINVAL; - if (ioctl(rmidi->fd, SND_RAWMIDI_IOCTL_OUTPUT_STATUS, status) < 0) + if (status->channel < 0 || status->channel > 1) + return -EINVAL; + if (ioctl(rmidi->fd, SND_RAWMIDI_IOCTL_CHANNEL_STATUS, status) < 0) return -errno; return 0; } -int snd_rawmidi_input_status(snd_rawmidi_t *rmidi, snd_rawmidi_input_status_t * status) +int snd_rawmidi_output_drain(snd_rawmidi_t *rmidi) { - if (!rmidi || !status) + int chn = SND_RAWMIDI_CHANNEL_OUTPUT; + if (!rmidi) return -EINVAL; - if (ioctl(rmidi->fd, SND_RAWMIDI_IOCTL_INPUT_STATUS, status) < 0) + if (ioctl(rmidi->fd, SND_RAWMIDI_IOCTL_CHANNEL_DRAIN, &chn) < 0) return -errno; return 0; } -int snd_rawmidi_drain_output(snd_rawmidi_t *rmidi) +int snd_rawmidi_channel_flush(snd_rawmidi_t *rmidi, int chn) { if (!rmidi) return -EINVAL; - if (ioctl(rmidi->fd, SND_RAWMIDI_IOCTL_DRAIN_OUTPUT) < 0) + if (chn < 0 || chn > 1) + return -EINVAL; + if (ioctl(rmidi->fd, SND_RAWMIDI_IOCTL_CHANNEL_FLUSH) < 0) return -errno; return 0; } -int snd_rawmidi_flush_output(snd_rawmidi_t *rmidi) +int snd_rawmidi_output_flush(snd_rawmidi_t *rmidi) { - if (!rmidi) - return -EINVAL; - if (ioctl(rmidi->fd, SND_RAWMIDI_IOCTL_FLUSH_OUTPUT) < 0) - return -errno; - return 0; + return snd_rawmidi_channel_flush(rmidi, SND_RAWMIDI_CHANNEL_OUTPUT); } -int snd_rawmidi_flush_input(snd_rawmidi_t *rmidi) +int snd_rawmidi_input_flush(snd_rawmidi_t *rmidi) { - if (!rmidi) - return -EINVAL; - if (ioctl(rmidi->fd, SND_RAWMIDI_IOCTL_FLUSH_INPUT) < 0) - return -errno; - return 0; + return snd_rawmidi_channel_flush(rmidi, SND_RAWMIDI_CHANNEL_INPUT); } ssize_t snd_rawmidi_write(snd_rawmidi_t *rmidi, const void *buffer, size_t size)