Recoded the universal switch interface...

This commit is contained in:
Jaroslav Kysela 1999-05-04 19:21:28 +00:00
parent a5b307a711
commit 6e72ca3977
8 changed files with 42 additions and 204 deletions

View 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;
}

View 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++;
}

View 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;

View 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;