]> git.alsa-project.org Git - alsa-lib.git/commitdiff
Recoded the universal switch interface...
authorJaroslav Kysela <perex@perex.cz>
Tue, 4 May 1999 19:21:28 +0000 (19:21 +0000)
committerJaroslav Kysela <perex@perex.cz>
Tue, 4 May 1999 19:21:28 +0000 (19:21 +0000)
include/control.h
include/mixer.h
include/pcm.h
include/rawmidi.h
src/control/control.c
src/mixer/mixer.c
src/pcm/pcm.c
src/rawmidi/rawmidi.c

index d32c1176317fdfd7c934258efd447381d3b6a8af..5fa336edb39aa335d3fec14164111fb916dcc2a8 100644 (file)
@@ -5,6 +5,13 @@
  *                                                                          *
  ****************************************************************************/
 
+typedef struct snd_ctl_callbacks {
+       void *private_data;     /* should be used by an application */
+       void (*rebuild) (void *private_data);
+       void (*xswitch) (void *private_data, int cmd, int iface, snd_switch_list_item_t *item);
+       void *reserved[29];     /* reserved for the future use - must be NULL!!! */
+} snd_ctl_callbacks_t;
+
 #ifdef __cplusplus
 extern "C" {
 #endif
@@ -51,6 +58,7 @@ int snd_ctl_rawmidi_output_switch_write(void *handle, int dev, snd_switch_t * sw
 int snd_ctl_rawmidi_input_switch_list(void *handle, int dev, snd_switch_list_t *list);
 int snd_ctl_rawmidi_input_switch_read(void *handle, int dev, snd_switch_t * sw);
 int snd_ctl_rawmidi_input_switch_write(void *handle, int dev, snd_switch_t * sw);
+int snd_ctl_read(void *handle, snd_ctl_callbacks_t * callbacks);
 
 #ifdef __cplusplus
 }
index c9ef66d2aaf1388d54325e5cf19eb04908f3ffb3..4bcf6a7c65cac0d59262b9309e567526cb61353d 100644 (file)
@@ -10,8 +10,7 @@ typedef struct snd_mixer_callbacks {
        void (*rebuild) (void *private_data);
        void (*element) (void *private_data, int cmd, snd_mixer_eid_t *eid);
        void (*group) (void *private_data, int cmd, snd_mixer_gid_t *gid);
-       void (*xswitch) (void *private_data, int cmd, snd_switch_list_item_t *item);
-       void *reserved[27];     /* reserved for the future use - must be NULL!!! */
+       void *reserved[28];     /* reserved for the future use - must be NULL!!! */
 } snd_mixer_callbacks_t;
 
 #ifdef __cplusplus
@@ -29,9 +28,6 @@ int snd_mixer_group(void *handle, snd_mixer_group_t * group);
 int snd_mixer_element_info(void *handle, snd_mixer_element_info_t * info);
 int snd_mixer_element_read(void *handle, snd_mixer_element_t * element);
 int snd_mixer_element_write(void *handle, snd_mixer_element_t * element);
-int snd_mixer_switch_list(void *handle, snd_switch_list_t * list);
-int snd_mixer_switch_read(void *handle, snd_switch_t * sw);
-int snd_mixer_switch_write(void *handle, snd_switch_t * sw);
 int snd_mixer_read(void *handle, snd_mixer_callbacks_t * callbacks);
 
 void snd_mixer_set_bit(unsigned int *bitmap, int bit, int val);
index 95c2a70f970f4ebef021bf7bd7f99b0d7bc946e3..a56badc6f55e0b925d5d662c232cfa6f0aecffd1 100644 (file)
@@ -20,12 +20,6 @@ int snd_pcm_block_mode(void *handle, int enable);
 int snd_pcm_info(void *handle, snd_pcm_info_t * info);
 int snd_pcm_playback_info(void *handle, snd_pcm_playback_info_t * info);
 int snd_pcm_record_info(void *handle, snd_pcm_record_info_t * info);
-int snd_pcm_playback_switch_list(void *handle, snd_switch_list_t * list);
-int snd_pcm_playback_switch_read(void *handle, snd_switch_t * sw);
-int snd_pcm_playback_switch_write(void *handle, snd_switch_t * sw);
-int snd_pcm_record_switch_list(void *handle, snd_switch_list_t * list);
-int snd_pcm_record_switch_read(void *handle, snd_switch_t * sw);
-int snd_pcm_record_switch_write(void *handle, snd_switch_t * sw);
 int snd_pcm_playback_format(void *handle, snd_pcm_format_t * format);
 int snd_pcm_record_format(void *handle, snd_pcm_format_t * format);
 int snd_pcm_playback_params(void *handle, snd_pcm_playback_params_t * params);
index 64250ff94e77d36434cb9003aa291a5ca16ed06d..53278279fba8d0d4e8388f444eb6a92580d9c1e9 100644 (file)
@@ -18,12 +18,6 @@ int snd_rawmidi_close(void *handle);
 int snd_rawmidi_file_descriptor(void *handle);
 int snd_rawmidi_block_mode(void *handle, int enable);
 int snd_rawmidi_info(void *handle, snd_rawmidi_info_t * info);
-int snd_rawmidi_output_switch_list(void *handle, snd_switch_list_t * list);
-int snd_rawmidi_output_switch_read(void *handle, snd_switch_t * sw);
-int snd_rawmidi_output_switch_write(void *handle, snd_switch_t * sw);
-int snd_rawmidi_input_switch_list(void *handle, snd_switch_list_t * list);
-int snd_rawmidi_input_switch_read(void *handle, snd_switch_t * sw);
-int snd_rawmidi_input_switch_write(void *handle, snd_switch_t * sw);
 int snd_rawmidi_output_params(void *handle, snd_rawmidi_output_params_t * params);
 int snd_rawmidi_input_params(void *handle, snd_rawmidi_input_params_t * params);
 int snd_rawmidi_output_status(void *handle, snd_rawmidi_output_status_t * status);
index 39840948645b976f9d909bab40416a9bdb0b3869..ce8b6324e5511196e437523a79f6f64b29e039fe 100644 (file)
@@ -450,3 +450,36 @@ int snd_ctl_rawmidi_input_switch_write(void *handle, int dev, snd_switch_t * sw)
                return -errno;
        return 0;
 }
+
+int snd_control_read(void *handle, snd_ctl_callbacks_t * callbacks)
+{
+       snd_ctl_t *ctl;
+       int result, count;
+       snd_ctl_read_t r;
+
+       ctl = (snd_ctl_t *) handle;
+       if (!ctl)
+               return -EINVAL;
+       count = 0;
+       while ((result = read(ctl->fd, &r, sizeof(r))) > 0) {
+               if (result != sizeof(r))
+                       return -EIO;
+               if (!callbacks)
+                       continue;
+               switch (r.cmd) {
+               case SND_CTL_READ_REBUILD:
+                       if (callbacks->rebuild)
+                               callbacks->rebuild(callbacks->private_data);
+                       break;
+               case SND_CTL_READ_SWITCH_VALUE:
+               case SND_CTL_READ_SWITCH_CHANGE:
+               case SND_CTL_READ_SWITCH_ADD:
+               case SND_CTL_READ_SWITCH_REMOVE:
+                       if (callbacks->xswitch)
+                               callbacks->xswitch(callbacks->private_data, r.cmd, r.data.sw.iface, &r.data.sw.switem);
+                       break;
+               }
+               count++;
+       }
+       return result >= 0 ? count : -errno;
+}
index a9a3234882cf1357309ccd3435f810da3136d98e..779caa831c52a4759176e5e43b39316ec25e28f4 100644 (file)
@@ -193,42 +193,6 @@ int snd_mixer_element_write(void *handle, snd_mixer_element_t * element)
        return 0;
 }
 
-int snd_mixer_switch_list(void *handle, snd_switch_list_t * list)
-{
-       snd_mixer_t *mixer;
-
-       mixer = (snd_mixer_t *) handle;
-       if (!mixer || !list)
-               return -EINVAL;
-       if (ioctl(mixer->fd, SND_MIXER_IOCTL_SWITCH_LIST, &list) < 0)
-               return -errno;
-       return 0;
-}
-
-int snd_mixer_switch_read(void *handle, snd_switch_t * sw)
-{
-       snd_mixer_t *mixer;
-
-       mixer = (snd_mixer_t *) handle;
-       if (!mixer || !sw || sw->name[0] == '\0')
-               return -EINVAL;
-       if (ioctl(mixer->fd, SND_MIXER_IOCTL_SWITCH_READ, sw) < 0)
-               return -errno;
-       return 0;
-}
-
-int snd_mixer_switch_write(void *handle, snd_switch_t * sw)
-{
-       snd_mixer_t *mixer;
-
-       mixer = (snd_mixer_t *) handle;
-       if (!mixer || !sw || sw->name[0] == '\0')
-               return -EINVAL;
-       if (ioctl(mixer->fd, SND_MIXER_IOCTL_SWITCH_WRITE, sw) < 0)
-               return -errno;
-       return 0;
-}
-
 int snd_mixer_read(void *handle, snd_mixer_callbacks_t * callbacks)
 {
        snd_mixer_t *mixer;
@@ -263,13 +227,6 @@ int snd_mixer_read(void *handle, snd_mixer_callbacks_t * callbacks)
                        if (callbacks->group)
                                callbacks->group(callbacks->private_data, r.cmd, &r.data.gid);
                        break;
-               case SND_MIXER_READ_SWITCH_VALUE:
-               case SND_MIXER_READ_SWITCH_CHANGE:
-               case SND_MIXER_READ_SWITCH_ADD:
-               case SND_MIXER_READ_SWITCH_REMOVE:
-                       if (callbacks->xswitch)
-                               callbacks->xswitch(callbacks->private_data, r.cmd, &r.data.switem);
-                       break;
                }
                count++;
        }
index 262ce9af23d871e4a9f3d68a13afc4c574f698ab..ea83c1c09da5d6c45d46bfdef78849e216443d77 100644 (file)
@@ -151,78 +151,6 @@ int snd_pcm_record_info(void *handle, snd_pcm_record_info_t * info)
        return 0;
 }
 
-int snd_pcm_playback_switch_list(void *handle, snd_switch_list_t * list)
-{
-       snd_pcm_t *pcm;
-
-       pcm = (snd_pcm_t *) handle;
-       if (!pcm || !list)
-               return -EINVAL;
-       if (ioctl(pcm->fd, SND_PCM_IOCTL_PSWITCH_LIST, &list) < 0)
-               return -errno;
-       return 0;
-}
-
-int snd_pcm_playback_switch_read(void *handle, snd_switch_t * sw)
-{
-       snd_pcm_t *pcm;
-
-       pcm = (snd_pcm_t *) handle;
-       if (!pcm || !sw || sw->name[0] == '\0')
-               return -EINVAL;
-       if (ioctl(pcm->fd, SND_PCM_IOCTL_PSWITCH_READ, sw) < 0)
-               return -errno;
-       return 0;
-}
-
-int snd_pcm_playback_switch_write(void *handle, snd_switch_t * sw)
-{
-       snd_pcm_t *pcm;
-
-       pcm = (snd_pcm_t *) handle;
-       if (!pcm || !sw || sw->name[0] == '\0')
-               return -EINVAL;
-       if (ioctl(pcm->fd, SND_PCM_IOCTL_PSWITCH_WRITE, sw) < 0)
-               return -errno;
-       return 0;
-}
-
-int snd_pcm_record_switch_list(void *handle, snd_switch_list_t * list)
-{
-       snd_pcm_t *pcm;
-
-       pcm = (snd_pcm_t *) handle;
-       if (!pcm || !list)
-               return -EINVAL;
-       if (ioctl(pcm->fd, SND_PCM_IOCTL_RSWITCH_LIST, list) < 0)
-               return -errno;
-       return 0;
-}
-
-int snd_pcm_record_switch_read(void *handle, snd_switch_t * sw)
-{
-       snd_pcm_t *pcm;
-
-       pcm = (snd_pcm_t *) handle;
-       if (!pcm || !sw || sw->name[0] == '\0')
-               return -EINVAL;
-       if (ioctl(pcm->fd, SND_PCM_IOCTL_RSWITCH_READ, sw) < 0)
-               return -errno;
-       return 0;
-}
-
-int snd_pcm_record_switch_write(void *handle, snd_switch_t * sw)
-{
-       snd_pcm_t *pcm;
-
-       pcm = (snd_pcm_t *) handle;
-       if (!pcm || !sw || sw->name[0] == '\0')
-               return -EINVAL;
-       if (ioctl(pcm->fd, SND_PCM_IOCTL_RSWITCH_WRITE, sw) < 0)
-               return -errno;
-       return 0;
-}
-
 int snd_pcm_playback_format(void *handle, snd_pcm_format_t * format)
 {
        snd_pcm_t *pcm;
index 95910af1d7fd696facac5e2a40c2f4d2147f3d58..9155b20f881deda820f3ce14acb0ba0145d89ca4 100644 (file)
@@ -127,78 +127,6 @@ int snd_rawmidi_info(void *handle, snd_rawmidi_info_t * info)
        return 0;
 }
 
-int snd_rawmidi_output_switch_list(void *handle, snd_switch_list_t * list)
-{
-       snd_rawmidi_t *rmidi;
-
-       rmidi = (snd_rawmidi_t *) handle;
-       if (!rmidi || !list)
-               return -EINVAL;
-       if (ioctl(rmidi->fd, SND_RAWMIDI_IOCTL_OSWITCH_LIST, list) < 0)
-               return -errno;
-       return 0;
-}
-
-int snd_rawmidi_output_switch_read(void *handle, snd_switch_t * sw)
-{
-       snd_rawmidi_t *rmidi;
-
-       rmidi = (snd_rawmidi_t *) handle;
-       if (!rmidi || !sw || sw->name[0] == '\0')
-               return -EINVAL;
-       if (ioctl(rmidi->fd, SND_RAWMIDI_IOCTL_OSWITCH_READ, sw) < 0)
-               return -errno;
-       return 0;
-}
-
-int snd_rawmidi_output_switch_write(void *handle, snd_switch_t * sw)
-{
-       snd_rawmidi_t *rmidi;
-
-       rmidi = (snd_rawmidi_t *) handle;
-       if (!rmidi || !sw || sw->name[0] == '\0')
-               return -EINVAL;
-       if (ioctl(rmidi->fd, SND_RAWMIDI_IOCTL_OSWITCH_WRITE, sw) < 0)
-               return -errno;
-       return 0;
-}
-
-int snd_rawmidi_input_switch_list(void *handle, snd_switch_list_t * list)
-{
-       snd_rawmidi_t *rmidi;
-
-       rmidi = (snd_rawmidi_t *) handle;
-       if (!rmidi)
-               return -EINVAL;
-       if (ioctl(rmidi->fd, SND_RAWMIDI_IOCTL_ISWITCH_LIST, list) < 0)
-               return -errno;
-       return 0;
-}
-
-int snd_rawmidi_input_switch_read(void *handle, snd_switch_t * sw)
-{
-       snd_rawmidi_t *rmidi;
-
-       rmidi = (snd_rawmidi_t *) handle;
-       if (!rmidi || !sw || sw->name[0] == '\0')
-               return -EINVAL;
-       if (ioctl(rmidi->fd, SND_RAWMIDI_IOCTL_ISWITCH_READ, sw) < 0)
-               return -errno;
-       return 0;
-}
-
-int snd_rawmidi_input_switch_write(void *handle, snd_switch_t * sw)
-{
-       snd_rawmidi_t *rmidi;
-
-       rmidi = (snd_rawmidi_t *) handle;
-       if (!rmidi || !sw || sw->name[0] == '\0')
-               return -EINVAL;
-       if (ioctl(rmidi->fd, SND_RAWMIDI_IOCTL_ISWITCH_WRITE, sw) < 0)
-               return -errno;
-       return 0;
-}
-
 int snd_rawmidi_output_params(void *handle, snd_rawmidi_output_params_t * params)
 {
        snd_rawmidi_t *rmidi;