- splitted pcm channels in two different devices to handle mmap correctly

- removed mmap control device
- reordered pcm shared and not shared code
- changed O_WRONLY oss pcm modifier in a more symmetric and elegant way
- changed slightly control interface
- added snd-debug-check
- uniformed null pointer check
- fixed a typo in linear plugin
This commit is contained in:
Abramo Bagnara 2000-01-08 20:11:33 +00:00
parent 62380b0f43
commit 63f5a79562
11 changed files with 263 additions and 216 deletions

View file

@ -171,15 +171,17 @@ int snd_ctl_pcm_info(snd_ctl_t *handle, int dev, snd_pcm_info_t * info)
return 0;
}
int snd_ctl_pcm_channel_info(snd_ctl_t *handle, int dev, int subdev, snd_pcm_channel_info_t * info)
int snd_ctl_pcm_channel_info(snd_ctl_t *handle, int dev, int chn, int subdev, snd_pcm_channel_info_t * info)
{
snd_ctl_t *ctl;
ctl = handle;
if (!ctl || !info || dev < 0 || subdev < 0)
if (!ctl || !info || dev < 0 || chn < 0 || chn > 1 || subdev < 0)
return -EINVAL;
if (ioctl(ctl->fd, SND_CTL_IOCTL_PCM_DEVICE, &dev) < 0)
return -errno;
if (ioctl(ctl->fd, SND_CTL_IOCTL_PCM_CHANNEL, &chn) < 0)
return -errno;
if (ioctl(ctl->fd, SND_CTL_IOCTL_PCM_SUBDEVICE, &subdev) < 0)
return -errno;
if (ioctl(ctl->fd, SND_CTL_IOCTL_PCM_CHANNEL_INFO, info) < 0)
@ -187,102 +189,98 @@ int snd_ctl_pcm_channel_info(snd_ctl_t *handle, int dev, int subdev, snd_pcm_cha
return 0;
}
int snd_ctl_pcm_prefer_subdevice(snd_ctl_t *handle, int dev, int subdev)
int snd_ctl_pcm_channel_prefer_subdevice(snd_ctl_t *handle, int dev, int chn, int subdev)
{
snd_ctl_t *ctl;
ctl = handle;
if (!ctl || dev < 0)
if (!ctl || dev < 0 || chn < 0 || chn > 1)
return -EINVAL;
if (ioctl(ctl->fd, SND_CTL_IOCTL_PCM_DEVICE, &dev) < 0)
return -errno;
if (ioctl(ctl->fd, SND_CTL_IOCTL_PCM_CHANNEL, &chn) < 0)
return -errno;
if (ioctl(ctl->fd, SND_CTL_IOCTL_PCM_PREFER_SUBDEVICE, &subdev) < 0)
return -errno;
return 0;
}
int snd_ctl_pcm_playback_switch_list(snd_ctl_t *handle, int dev, snd_switch_list_t *list)
int snd_ctl_pcm_channel_switch_list(snd_ctl_t *handle, int dev, int chn, snd_switch_list_t *list)
{
snd_ctl_t *ctl;
ctl = handle;
if (!ctl || dev < 0 || !list)
if (!ctl || dev < 0 || chn < 0 || chn > 1 || !list)
return -EINVAL;
if (ioctl(ctl->fd, SND_CTL_IOCTL_PCM_DEVICE, &dev) < 0)
return -errno;
if (ioctl(ctl->fd, SND_CTL_IOCTL_PCM_PSWITCH_LIST, list) < 0)
if (ioctl(ctl->fd, SND_CTL_IOCTL_PCM_CHANNEL, &chn) < 0)
return -errno;
if (ioctl(ctl->fd, SND_CTL_IOCTL_PCM_SWITCH_LIST, list) < 0)
return -errno;
return 0;
}
int snd_ctl_pcm_playback_switch_list(snd_ctl_t *handle, int dev, snd_switch_list_t *list)
{
return snd_ctl_pcm_channel_switch_list(handle, dev, SND_PCM_CHANNEL_PLAYBACK, list);
}
int snd_ctl_pcm_capture_switch_list(snd_ctl_t *handle, int dev, snd_switch_list_t *list)
{
return snd_ctl_pcm_channel_switch_list(handle, dev, SND_PCM_CHANNEL_CAPTURE, list);
}
int snd_ctl_pcm_channel_switch_read(snd_ctl_t *handle, int dev, int chn, snd_switch_t * sw)
{
snd_ctl_t *ctl;
ctl = handle;
if (!ctl || !sw || dev < 0 || chn < 0 || chn > 1 || sw->name[0] == '\0')
return -EINVAL;
if (ioctl(ctl->fd, SND_CTL_IOCTL_PCM_DEVICE, &dev) < 0)
return -errno;
if (ioctl(ctl->fd, SND_CTL_IOCTL_PCM_CHANNEL, &chn) < 0)
return -errno;
if (ioctl(ctl->fd, SND_CTL_IOCTL_PCM_SWITCH_READ, sw) < 0)
return -errno;
return 0;
}
int snd_ctl_pcm_playback_switch_read(snd_ctl_t *handle, int dev, snd_switch_t * sw)
{
return snd_ctl_pcm_channel_switch_read(handle, dev, SND_PCM_CHANNEL_PLAYBACK, sw);
}
int snd_ctl_pcm_capture_switch_read(snd_ctl_t *handle, int dev, snd_switch_t * sw)
{
return snd_ctl_pcm_channel_switch_read(handle, dev, SND_PCM_CHANNEL_CAPTURE, sw);
}
int snd_ctl_pcm_channel_switch_write(snd_ctl_t *handle, int dev, int chn, snd_switch_t * sw)
{
snd_ctl_t *ctl;
ctl = handle;
if (!ctl || !sw || dev < 0 || sw->name[0] == '\0')
if (!ctl || !sw || dev < 0 || chn < 0 || chn > 1 || sw->name[0] == '\0')
return -EINVAL;
if (ioctl(ctl->fd, SND_CTL_IOCTL_PCM_DEVICE, &dev) < 0)
return -errno;
if (ioctl(ctl->fd, SND_CTL_IOCTL_PCM_PSWITCH_READ, sw) < 0)
if (ioctl(ctl->fd, SND_CTL_IOCTL_PCM_CHANNEL, &chn) < 0)
return -errno;
if (ioctl(ctl->fd, SND_CTL_IOCTL_PCM_SWITCH_WRITE, sw) < 0)
return -errno;
return 0;
}
int snd_ctl_pcm_playback_switch_write(snd_ctl_t *handle, int dev, snd_switch_t * sw)
{
snd_ctl_t *ctl;
ctl = handle;
if (!ctl || !sw || dev < 0 || sw->name[0] == '\0')
return -EINVAL;
if (ioctl(ctl->fd, SND_CTL_IOCTL_PCM_DEVICE, &dev) < 0)
return -errno;
if (ioctl(ctl->fd, SND_CTL_IOCTL_PCM_PSWITCH_WRITE, sw) < 0)
return -errno;
return 0;
}
int snd_ctl_pcm_capture_switch_list(snd_ctl_t *handle, int dev, snd_switch_list_t * list)
{
snd_ctl_t *ctl;
ctl = handle;
if (!ctl || !list || dev < 0)
return -EINVAL;
if (ioctl(ctl->fd, SND_CTL_IOCTL_PCM_DEVICE, &dev) < 0)
return -errno;
if (ioctl(ctl->fd, SND_CTL_IOCTL_PCM_CSWITCH_LIST, list) < 0)
return -errno;
return 0;
}
int snd_ctl_pcm_capture_switch_read(snd_ctl_t *handle, int dev, snd_switch_t * sw)
{
snd_ctl_t *ctl;
ctl = handle;
if (!ctl || !sw || dev < 0 || sw->name[0] == '\0')
return -EINVAL;
if (ioctl(ctl->fd, SND_CTL_IOCTL_PCM_DEVICE, &dev) < 0)
return -errno;
if (ioctl(ctl->fd, SND_CTL_IOCTL_PCM_CSWITCH_READ, sw) < 0)
return -errno;
return 0;
return snd_ctl_pcm_channel_switch_write(handle, dev, SND_PCM_CHANNEL_PLAYBACK, sw);
}
int snd_ctl_pcm_capture_switch_write(snd_ctl_t *handle, int dev, snd_switch_t * sw)
{
snd_ctl_t *ctl;
ctl = handle;
if (!ctl || !sw || dev < 0 || sw->name[0] == '\0')
return -EINVAL;
if (ioctl(ctl->fd, SND_CTL_IOCTL_PCM_DEVICE, &dev) < 0)
return -errno;
if (ioctl(ctl->fd, SND_CTL_IOCTL_PCM_CSWITCH_WRITE, sw) < 0)
return -errno;
return 0;
return snd_ctl_pcm_channel_switch_write(handle, dev, SND_PCM_CHANNEL_CAPTURE, sw);
}
int snd_ctl_mixer_info(snd_ctl_t *handle, int dev, snd_mixer_info_t * info)