]> git.alsa-project.org Git - alsa-lib.git/commitdiff
uniformed alsa-lib interfaces
authorAbramo Bagnara <abramo@alsa-project.org>
Sun, 9 Jan 2000 22:44:52 +0000 (22:44 +0000)
committerAbramo Bagnara <abramo@alsa-project.org>
Sun, 9 Jan 2000 22:44:52 +0000 (22:44 +0000)
include/pcm.h
include/rawmidi.h
src/control/control.c
src/pcm/pcm.c
src/pcm/pcm_plugin.c
src/rawmidi/rawmidi.c

index 8fe0a6ccc6cff152bbc74603e23f12e89124ca87..47dd2e0548306a6730c83a14eeb32788198efc81 100644 (file)
@@ -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);
index c14d9da6deec273249ded1f8d0f973391cffc7f0..ccaea8dca78bfbb75bc6366a8873eafb761752a4 100644 (file)
@@ -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);
 
index 67be2e49c9c9509e247fa7c076184e57831184b6..74618c3d0ba4565666cdefdf181aa77c4909b09f 100644 (file)
@@ -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)
index 177138e859940a7d5cd9c7b0fc4a9edb431ee743..ccb5b93422b39f8c26ffe4aaada97a486acf3a72 100644 (file)
@@ -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;
        }
index 717f5ae9df7749a5c9757ed2d8b32dbace3be44e..033473bfd0a422f03dd65b47359a3a148c0bf5e9 100644 (file)
@@ -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)
index 3625a4b11acd45ecd1d13441382c895d5e19b856..e1f1e1ad0baf3050023c3a0e835fafba5b862732 100644 (file)
@@ -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)