First step toward encapsulation

This commit is contained in:
Abramo Bagnara 2001-01-29 14:27:53 +00:00
parent d44c657826
commit 70809b1835
13 changed files with 997 additions and 391 deletions

View file

@ -31,8 +31,8 @@
#include "asoundlib.h"
#include "control_local.h"
#define SND_FILE_CONTROL "/dev/snd/controlC%i"
#define SND_CTL_VERSION_MAX SND_PROTOCOL_VERSION(2, 0, 0)
#define SNDRV_FILE_CONTROL "/dev/snd/controlC%i"
#define SNDRV_CTL_VERSION_MAX SNDRV_PROTOCOL_VERSION(2, 0, 0)
typedef struct {
int card;
@ -63,7 +63,7 @@ static int snd_ctl_hw_poll_descriptor(snd_ctl_t *handle)
static int snd_ctl_hw_hw_info(snd_ctl_t *handle, snd_ctl_hw_info_t *info)
{
snd_ctl_hw_t *hw = handle->private;
if (ioctl(hw->fd, SND_CTL_IOCTL_HW_INFO, info) < 0)
if (ioctl(hw->fd, SNDRV_CTL_IOCTL_HW_INFO, info) < 0)
return -errno;
return 0;
}
@ -71,7 +71,7 @@ static int snd_ctl_hw_hw_info(snd_ctl_t *handle, snd_ctl_hw_info_t *info)
static int snd_ctl_hw_clist(snd_ctl_t *handle, snd_control_list_t *list)
{
snd_ctl_hw_t *hw = handle->private;
if (ioctl(hw->fd, SND_CTL_IOCTL_CONTROL_LIST, list) < 0)
if (ioctl(hw->fd, SNDRV_CTL_IOCTL_CONTROL_LIST, list) < 0)
return -errno;
return 0;
}
@ -79,7 +79,7 @@ static int snd_ctl_hw_clist(snd_ctl_t *handle, snd_control_list_t *list)
static int snd_ctl_hw_cinfo(snd_ctl_t *handle, snd_control_info_t *info)
{
snd_ctl_hw_t *hw = handle->private;
if (ioctl(hw->fd, SND_CTL_IOCTL_CONTROL_INFO, info) < 0)
if (ioctl(hw->fd, SNDRV_CTL_IOCTL_CONTROL_INFO, info) < 0)
return -errno;
return 0;
}
@ -87,7 +87,7 @@ static int snd_ctl_hw_cinfo(snd_ctl_t *handle, snd_control_info_t *info)
static int snd_ctl_hw_cread(snd_ctl_t *handle, snd_control_t *control)
{
snd_ctl_hw_t *hw = handle->private;
if (ioctl(hw->fd, SND_CTL_IOCTL_CONTROL_READ, control) < 0)
if (ioctl(hw->fd, SNDRV_CTL_IOCTL_CONTROL_READ, control) < 0)
return -errno;
return 0;
}
@ -95,7 +95,7 @@ static int snd_ctl_hw_cread(snd_ctl_t *handle, snd_control_t *control)
static int snd_ctl_hw_cwrite(snd_ctl_t *handle, snd_control_t *control)
{
snd_ctl_hw_t *hw = handle->private;
if (ioctl(hw->fd, SND_CTL_IOCTL_CONTROL_WRITE, control) < 0)
if (ioctl(hw->fd, SNDRV_CTL_IOCTL_CONTROL_WRITE, control) < 0)
return -errno;
return 0;
}
@ -103,7 +103,7 @@ static int snd_ctl_hw_cwrite(snd_ctl_t *handle, snd_control_t *control)
static int snd_ctl_hw_hwdep_next_device(snd_ctl_t *handle, int * device)
{
snd_ctl_hw_t *hw = handle->private;
if (ioctl(hw->fd, SND_CTL_IOCTL_HWDEP_NEXT_DEVICE, device) < 0)
if (ioctl(hw->fd, SNDRV_CTL_IOCTL_HWDEP_NEXT_DEVICE, device) < 0)
return -errno;
return 0;
}
@ -111,7 +111,7 @@ static int snd_ctl_hw_hwdep_next_device(snd_ctl_t *handle, int * device)
static int snd_ctl_hw_hwdep_info(snd_ctl_t *handle, snd_hwdep_info_t * info)
{
snd_ctl_hw_t *hw = handle->private;
if (ioctl(hw->fd, SND_CTL_IOCTL_HWDEP_INFO, info) < 0)
if (ioctl(hw->fd, SNDRV_CTL_IOCTL_HWDEP_INFO, info) < 0)
return -errno;
return 0;
}
@ -119,7 +119,7 @@ static int snd_ctl_hw_hwdep_info(snd_ctl_t *handle, snd_hwdep_info_t * info)
static int snd_ctl_hw_pcm_next_device(snd_ctl_t *handle, int * device)
{
snd_ctl_hw_t *hw = handle->private;
if (ioctl(hw->fd, SND_CTL_IOCTL_PCM_NEXT_DEVICE, device) < 0)
if (ioctl(hw->fd, SNDRV_CTL_IOCTL_PCM_NEXT_DEVICE, device) < 0)
return -errno;
return 0;
}
@ -127,7 +127,7 @@ static int snd_ctl_hw_pcm_next_device(snd_ctl_t *handle, int * device)
static int snd_ctl_hw_pcm_info(snd_ctl_t *handle, snd_pcm_info_t * info)
{
snd_ctl_hw_t *hw = handle->private;
if (ioctl(hw->fd, SND_CTL_IOCTL_PCM_INFO, info) < 0)
if (ioctl(hw->fd, SNDRV_CTL_IOCTL_PCM_INFO, info) < 0)
return -errno;
return 0;
}
@ -135,7 +135,7 @@ static int snd_ctl_hw_pcm_info(snd_ctl_t *handle, snd_pcm_info_t * info)
static int snd_ctl_hw_pcm_prefer_subdevice(snd_ctl_t *handle, int subdev)
{
snd_ctl_hw_t *hw = handle->private;
if (ioctl(hw->fd, SND_CTL_IOCTL_PCM_PREFER_SUBDEVICE, &subdev) < 0)
if (ioctl(hw->fd, SNDRV_CTL_IOCTL_PCM_PREFER_SUBDEVICE, &subdev) < 0)
return -errno;
return 0;
}
@ -143,7 +143,7 @@ static int snd_ctl_hw_pcm_prefer_subdevice(snd_ctl_t *handle, int subdev)
static int snd_ctl_hw_rawmidi_next_device(snd_ctl_t *handle, int * device)
{
snd_ctl_hw_t *hw = handle->private;
if (ioctl(hw->fd, SND_CTL_IOCTL_RAWMIDI_NEXT_DEVICE, device) < 0)
if (ioctl(hw->fd, SNDRV_CTL_IOCTL_RAWMIDI_NEXT_DEVICE, device) < 0)
return -errno;
return 0;
}
@ -151,7 +151,7 @@ static int snd_ctl_hw_rawmidi_next_device(snd_ctl_t *handle, int * device)
static int snd_ctl_hw_rawmidi_info(snd_ctl_t *handle, snd_rawmidi_info_t * info)
{
snd_ctl_hw_t *hw = handle->private;
if (ioctl(hw->fd, SND_CTL_IOCTL_RAWMIDI_INFO, info) < 0)
if (ioctl(hw->fd, SNDRV_CTL_IOCTL_RAWMIDI_INFO, info) < 0)
return -errno;
return 0;
}
@ -159,7 +159,7 @@ static int snd_ctl_hw_rawmidi_info(snd_ctl_t *handle, snd_rawmidi_info_t * info)
static int snd_ctl_hw_rawmidi_prefer_subdevice(snd_ctl_t *handle, int subdev)
{
snd_ctl_hw_t *hw = handle->private;
if (ioctl(hw->fd, SND_CTL_IOCTL_RAWMIDI_PREFER_SUBDEVICE, &subdev) < 0)
if (ioctl(hw->fd, SNDRV_CTL_IOCTL_RAWMIDI_PREFER_SUBDEVICE, &subdev) < 0)
return -errno;
return 0;
}
@ -200,18 +200,18 @@ int snd_ctl_hw_open(snd_ctl_t **handle, char *name, int card)
*handle = NULL;
assert(card >= 0 && card < 32);
sprintf(filename, SND_FILE_CONTROL, card);
sprintf(filename, SNDRV_FILE_CONTROL, card);
if ((fd = open(filename, O_RDWR)) < 0) {
snd_card_load(card);
if ((fd = open(filename, O_RDWR)) < 0)
return -errno;
}
if (ioctl(fd, SND_CTL_IOCTL_PVERSION, &ver) < 0) {
if (ioctl(fd, SNDRV_CTL_IOCTL_PVERSION, &ver) < 0) {
close(fd);
return -errno;
}
if (SND_PROTOCOL_INCOMPATIBLE(ver, SND_CTL_VERSION_MAX)) {
if (SNDRV_PROTOCOL_INCOMPATIBLE(ver, SNDRV_CTL_VERSION_MAX)) {
close(fd);
return -SND_ERROR_INCOMPATIBLE_VERSION;
}

View file

@ -121,7 +121,7 @@ static int snd_ctl_shm_hw_info(snd_ctl_t *ctl, snd_ctl_hw_info_t *info)
volatile snd_ctl_shm_ctrl_t *ctrl = shm->ctrl;
int err;
// ctrl->u.hw_info = *info;
ctrl->cmd = SND_CTL_IOCTL_HW_INFO;
ctrl->cmd = SNDRV_CTL_IOCTL_HW_INFO;
err = snd_ctl_shm_action(ctl);
if (err < 0)
return err;
@ -140,7 +140,7 @@ static int snd_ctl_shm_clist(snd_ctl_t *ctl, snd_control_list_t *list)
if (bytes > maxsize)
return -EINVAL;
ctrl->u.clist = *list;
ctrl->cmd = SND_CTL_IOCTL_CONTROL_LIST;
ctrl->cmd = SNDRV_CTL_IOCTL_CONTROL_LIST;
err = snd_ctl_shm_action(ctl);
if (err < 0)
return err;
@ -156,7 +156,7 @@ static int snd_ctl_shm_cinfo(snd_ctl_t *ctl, snd_control_info_t *info)
volatile snd_ctl_shm_ctrl_t *ctrl = shm->ctrl;
int err;
ctrl->u.cinfo = *info;
ctrl->cmd = SND_CTL_IOCTL_CONTROL_INFO;
ctrl->cmd = SNDRV_CTL_IOCTL_CONTROL_INFO;
err = snd_ctl_shm_action(ctl);
if (err < 0)
return err;
@ -170,7 +170,7 @@ static int snd_ctl_shm_cread(snd_ctl_t *ctl, snd_control_t *control)
volatile snd_ctl_shm_ctrl_t *ctrl = shm->ctrl;
int err;
ctrl->u.cread = *control;
ctrl->cmd = SND_CTL_IOCTL_CONTROL_READ;
ctrl->cmd = SNDRV_CTL_IOCTL_CONTROL_READ;
err = snd_ctl_shm_action(ctl);
if (err < 0)
return err;
@ -184,7 +184,7 @@ static int snd_ctl_shm_cwrite(snd_ctl_t *ctl, snd_control_t *control)
volatile snd_ctl_shm_ctrl_t *ctrl = shm->ctrl;
int err;
ctrl->u.cwrite = *control;
ctrl->cmd = SND_CTL_IOCTL_CONTROL_WRITE;
ctrl->cmd = SNDRV_CTL_IOCTL_CONTROL_WRITE;
err = snd_ctl_shm_action(ctl);
if (err < 0)
return err;
@ -198,7 +198,7 @@ static int snd_ctl_shm_hwdep_next_device(snd_ctl_t *ctl, int * device)
volatile snd_ctl_shm_ctrl_t *ctrl = shm->ctrl;
int err;
ctrl->u.device = *device;
ctrl->cmd = SND_CTL_IOCTL_HWDEP_NEXT_DEVICE;
ctrl->cmd = SNDRV_CTL_IOCTL_HWDEP_NEXT_DEVICE;
err = snd_ctl_shm_action(ctl);
if (err < 0)
return err;
@ -212,7 +212,7 @@ static int snd_ctl_shm_hwdep_info(snd_ctl_t *ctl, snd_hwdep_info_t * info)
volatile snd_ctl_shm_ctrl_t *ctrl = shm->ctrl;
int err;
ctrl->u.hwdep_info = *info;
ctrl->cmd = SND_CTL_IOCTL_HWDEP_INFO;
ctrl->cmd = SNDRV_CTL_IOCTL_HWDEP_INFO;
err = snd_ctl_shm_action(ctl);
if (err < 0)
return err;
@ -226,7 +226,7 @@ static int snd_ctl_shm_pcm_next_device(snd_ctl_t *ctl, int * device)
volatile snd_ctl_shm_ctrl_t *ctrl = shm->ctrl;
int err;
ctrl->u.device = *device;
ctrl->cmd = SND_CTL_IOCTL_PCM_NEXT_DEVICE;
ctrl->cmd = SNDRV_CTL_IOCTL_PCM_NEXT_DEVICE;
err = snd_ctl_shm_action(ctl);
if (err < 0)
return err;
@ -240,7 +240,7 @@ static int snd_ctl_shm_pcm_info(snd_ctl_t *ctl, snd_pcm_info_t * info)
volatile snd_ctl_shm_ctrl_t *ctrl = shm->ctrl;
int err;
ctrl->u.pcm_info = *info;
ctrl->cmd = SND_CTL_IOCTL_PCM_INFO;
ctrl->cmd = SNDRV_CTL_IOCTL_PCM_INFO;
err = snd_ctl_shm_action(ctl);
if (err < 0)
return err;
@ -254,7 +254,7 @@ static int snd_ctl_shm_pcm_prefer_subdevice(snd_ctl_t *ctl, int subdev)
volatile snd_ctl_shm_ctrl_t *ctrl = shm->ctrl;
int err;
ctrl->u.pcm_prefer_subdevice = subdev;
ctrl->cmd = SND_CTL_IOCTL_PCM_PREFER_SUBDEVICE;
ctrl->cmd = SNDRV_CTL_IOCTL_PCM_PREFER_SUBDEVICE;
err = snd_ctl_shm_action(ctl);
if (err < 0)
return err;
@ -267,7 +267,7 @@ static int snd_ctl_shm_rawmidi_next_device(snd_ctl_t *ctl, int * device)
volatile snd_ctl_shm_ctrl_t *ctrl = shm->ctrl;
int err;
ctrl->u.device = *device;
ctrl->cmd = SND_CTL_IOCTL_RAWMIDI_NEXT_DEVICE;
ctrl->cmd = SNDRV_CTL_IOCTL_RAWMIDI_NEXT_DEVICE;
err = snd_ctl_shm_action(ctl);
if (err < 0)
return err;
@ -281,7 +281,7 @@ static int snd_ctl_shm_rawmidi_info(snd_ctl_t *ctl, snd_rawmidi_info_t * info)
volatile snd_ctl_shm_ctrl_t *ctrl = shm->ctrl;
int err;
ctrl->u.rawmidi_info = *info;
ctrl->cmd = SND_CTL_IOCTL_RAWMIDI_INFO;
ctrl->cmd = SNDRV_CTL_IOCTL_RAWMIDI_INFO;
err = snd_ctl_shm_action(ctl);
if (err < 0)
return err;
@ -295,7 +295,7 @@ static int snd_ctl_shm_rawmidi_prefer_subdevice(snd_ctl_t *ctl, int subdev)
volatile snd_ctl_shm_ctrl_t *ctrl = shm->ctrl;
int err;
ctrl->u.rawmidi_prefer_subdevice = subdev;
ctrl->cmd = SND_CTL_IOCTL_RAWMIDI_PREFER_SUBDEVICE;
ctrl->cmd = SNDRV_CTL_IOCTL_RAWMIDI_PREFER_SUBDEVICE;
err = snd_ctl_shm_action(ctl);
if (err < 0)
return err;