Fixed snd_*_card() wrt aserver

This commit is contained in:
Abramo Bagnara 2000-12-23 16:13:38 +00:00
parent 80c3adaace
commit c1ad051636
7 changed files with 38 additions and 48 deletions

View file

@ -374,8 +374,7 @@ int pcm_shm_cmd(client_t *client)
pcm = client->device.pcm.handle;
switch (cmd) {
case SND_PCM_IOCTL_CARD:
ctrl->result = 0;
ctrl->u.card = snd_pcm_card(pcm);
ctrl->result = snd_pcm_card(pcm);
break;
case SND_PCM_IOCTL_ASYNC:
ctrl->result = snd_pcm_async(pcm, ctrl->u.async.sig, ctrl->u.async.pid);
@ -631,10 +630,10 @@ int ctl_shm_cmd(client_t *client)
case SND_CTL_IOCTL_CLOSE:
client->ops->close(client);
break;
case SND_PCM_IOCTL_CARD:
ctrl->result = 0;
return shm_ack_fd(client, snd_ctl_card(ctl));
case SND_PCM_IOCTL_POLL_DESCRIPTOR:
case SND_CTL_IOCTL_CARD:
ctrl->result = snd_ctl_card(ctl);
break;
case SND_CTL_IOCTL_POLL_DESCRIPTOR:
ctrl->result = 0;
return shm_ack_fd(client, snd_ctl_poll_descriptor(ctl));
default:

View file

@ -38,7 +38,6 @@ typedef struct {
size_t hw_ptr;
size_t appl_ptr;
union {
int card;
struct {
int sig;
pid_t pid;

View file

@ -106,21 +106,21 @@ int mask_single(const mask_t *mask);
int snd_pcm_hw_params_any(snd_pcm_t *pcm, snd_pcm_hw_params_t *params);
int snd_pcm_hw_params_near(snd_pcm_t *pcm, snd_pcm_hw_params_t *params,
unsigned int par, unsigned int val);
unsigned int var, unsigned int val);
int snd_pcm_hw_params_min(snd_pcm_t *pcm, snd_pcm_hw_params_t *params,
unsigned int par, unsigned int val);
unsigned int var, unsigned int val);
int snd_pcm_hw_params_max(snd_pcm_t *pcm, snd_pcm_hw_params_t *params,
unsigned int par, unsigned int val);
unsigned int var, unsigned int val);
int snd_pcm_hw_params_minmax(snd_pcm_t *pcm, snd_pcm_hw_params_t *params,
unsigned int par, unsigned int min, unsigned int max);
unsigned int var, unsigned int min, unsigned int max);
int snd_pcm_hw_params_first(snd_pcm_t *pcm, snd_pcm_hw_params_t *params,
unsigned int par);
int snd_pcm_hw_params_last(snd_pcm_t *pcm, snd_pcm_hw_params_t *params,
unsigned int par);
int snd_pcm_hw_params_set(snd_pcm_t *pcm, snd_pcm_hw_params_t *params,
unsigned int par, unsigned int val);
unsigned int var, unsigned int val);
int snd_pcm_hw_params_mask(snd_pcm_t *pcm, snd_pcm_hw_params_t *params,
unsigned int par, const mask_t *mask);
unsigned int var, const mask_t *mask);
int snd_pcm_hw_params_info_rate(const snd_pcm_hw_params_t *params,
unsigned int *rate_num,
unsigned int *rate_den);

View file

@ -200,7 +200,7 @@ int snd_ctl_open(snd_ctl_t **ctlp, char *name)
err = sscanf(name, "hw:%d", &card);
if (err == 1)
return snd_ctl_hw_open(ctlp, NULL, card);
err = sscanf(name, "shm:%256s,%256s", socket, sname);
err = sscanf(name, "shm:%256[^,],%256[^,]", socket, sname);
if (err == 2)
return snd_ctl_shm_open(ctlp, NULL, socket, sname);
ERR("Unknown control %s", name);

View file

@ -39,7 +39,7 @@
typedef struct {
int socket;
void *ctrl;
volatile snd_ctl_shm_ctrl_t *ctrl;
} snd_ctl_shm_t;
extern int receive_fd(int socket, void *data, size_t len, int *fd);
@ -49,7 +49,7 @@ static int snd_ctl_shm_action(snd_ctl_t *ctl)
snd_ctl_shm_t *shm = ctl->private;
int err;
char buf[1];
snd_ctl_shm_ctrl_t *ctrl = shm->ctrl;
volatile snd_ctl_shm_ctrl_t *ctrl = shm->ctrl;
err = write(shm->socket, buf, 1);
if (err != 1)
return -EBADFD;
@ -68,7 +68,7 @@ static int snd_ctl_shm_action_fd(snd_ctl_t *ctl, int *fd)
snd_ctl_shm_t *shm = ctl->private;
int err;
char buf[1];
snd_ctl_shm_ctrl_t *ctrl = shm->ctrl;
volatile snd_ctl_shm_ctrl_t *ctrl = shm->ctrl;
err = write(shm->socket, buf, 1);
if (err != 1)
return -EBADFD;
@ -85,7 +85,7 @@ static int snd_ctl_shm_action_fd(snd_ctl_t *ctl, int *fd)
static int snd_ctl_shm_close(snd_ctl_t *ctl)
{
snd_ctl_shm_t *shm = ctl->private;
snd_ctl_shm_ctrl_t *ctrl = shm->ctrl;
volatile snd_ctl_shm_ctrl_t *ctrl = shm->ctrl;
int result;
ctrl->cmd = SND_CTL_IOCTL_CLOSE;
result = snd_ctl_shm_action(ctl);
@ -98,19 +98,15 @@ static int snd_ctl_shm_close(snd_ctl_t *ctl)
static int snd_ctl_shm_card(snd_ctl_t *ctl)
{
snd_ctl_shm_t *shm = ctl->private;
snd_ctl_shm_ctrl_t *ctrl = shm->ctrl;
int card, err;
volatile snd_ctl_shm_ctrl_t *ctrl = shm->ctrl;
ctrl->cmd = SND_CTL_IOCTL_CARD;
err = snd_ctl_shm_action_fd(ctl, &card);
if (err < 0)
return err;
return card;
return snd_ctl_shm_action(ctl);
}
static int snd_ctl_shm_poll_descriptor(snd_ctl_t *ctl)
{
snd_ctl_shm_t *shm = ctl->private;
snd_ctl_shm_ctrl_t *ctrl = shm->ctrl;
volatile snd_ctl_shm_ctrl_t *ctrl = shm->ctrl;
int fd, err;
ctrl->cmd = SND_CTL_IOCTL_POLL_DESCRIPTOR;
err = snd_ctl_shm_action_fd(ctl, &fd);
@ -122,7 +118,7 @@ static int snd_ctl_shm_poll_descriptor(snd_ctl_t *ctl)
static int snd_ctl_shm_hw_info(snd_ctl_t *ctl, snd_ctl_hw_info_t *info)
{
snd_ctl_shm_t *shm = ctl->private;
snd_ctl_shm_ctrl_t *ctrl = shm->ctrl;
volatile snd_ctl_shm_ctrl_t *ctrl = shm->ctrl;
int err;
// ctrl->u.hw_info = *info;
ctrl->cmd = SND_CTL_IOCTL_HW_INFO;
@ -136,7 +132,7 @@ static int snd_ctl_shm_hw_info(snd_ctl_t *ctl, snd_ctl_hw_info_t *info)
static int snd_ctl_shm_clist(snd_ctl_t *ctl, snd_control_list_t *list)
{
snd_ctl_shm_t *shm = ctl->private;
snd_ctl_shm_ctrl_t *ctrl = shm->ctrl;
volatile snd_ctl_shm_ctrl_t *ctrl = shm->ctrl;
size_t maxsize = CTL_SHM_DATA_MAXLEN;
size_t bytes = list->controls_request * sizeof(*list->pids);
int err;
@ -150,14 +146,14 @@ static int snd_ctl_shm_clist(snd_ctl_t *ctl, snd_control_list_t *list)
return err;
*list = ctrl->u.clist;
list->pids = pids;
memcpy(pids, ctrl->data, bytes);
memcpy(pids, (void *)ctrl->data, bytes);
return err;
}
static int snd_ctl_shm_cinfo(snd_ctl_t *ctl, snd_control_info_t *info)
{
snd_ctl_shm_t *shm = ctl->private;
snd_ctl_shm_ctrl_t *ctrl = shm->ctrl;
volatile snd_ctl_shm_ctrl_t *ctrl = shm->ctrl;
int err;
ctrl->u.cinfo = *info;
ctrl->cmd = SND_CTL_IOCTL_CONTROL_INFO;
@ -171,7 +167,7 @@ static int snd_ctl_shm_cinfo(snd_ctl_t *ctl, snd_control_info_t *info)
static int snd_ctl_shm_cread(snd_ctl_t *ctl, snd_control_t *control)
{
snd_ctl_shm_t *shm = ctl->private;
snd_ctl_shm_ctrl_t *ctrl = shm->ctrl;
volatile snd_ctl_shm_ctrl_t *ctrl = shm->ctrl;
int err;
ctrl->u.cread = *control;
ctrl->cmd = SND_CTL_IOCTL_CONTROL_READ;
@ -185,7 +181,7 @@ static int snd_ctl_shm_cread(snd_ctl_t *ctl, snd_control_t *control)
static int snd_ctl_shm_cwrite(snd_ctl_t *ctl, snd_control_t *control)
{
snd_ctl_shm_t *shm = ctl->private;
snd_ctl_shm_ctrl_t *ctrl = shm->ctrl;
volatile snd_ctl_shm_ctrl_t *ctrl = shm->ctrl;
int err;
ctrl->u.cwrite = *control;
ctrl->cmd = SND_CTL_IOCTL_CONTROL_WRITE;
@ -199,7 +195,7 @@ static int snd_ctl_shm_cwrite(snd_ctl_t *ctl, snd_control_t *control)
static int snd_ctl_shm_hwdep_next_device(snd_ctl_t *ctl, int * device)
{
snd_ctl_shm_t *shm = ctl->private;
snd_ctl_shm_ctrl_t *ctrl = shm->ctrl;
volatile snd_ctl_shm_ctrl_t *ctrl = shm->ctrl;
int err;
ctrl->u.device = *device;
ctrl->cmd = SND_CTL_IOCTL_HWDEP_NEXT_DEVICE;
@ -213,7 +209,7 @@ static int snd_ctl_shm_hwdep_next_device(snd_ctl_t *ctl, int * device)
static int snd_ctl_shm_hwdep_info(snd_ctl_t *ctl, snd_hwdep_info_t * info)
{
snd_ctl_shm_t *shm = ctl->private;
snd_ctl_shm_ctrl_t *ctrl = shm->ctrl;
volatile snd_ctl_shm_ctrl_t *ctrl = shm->ctrl;
int err;
ctrl->u.hwdep_info = *info;
ctrl->cmd = SND_CTL_IOCTL_HWDEP_INFO;
@ -227,7 +223,7 @@ static int snd_ctl_shm_hwdep_info(snd_ctl_t *ctl, snd_hwdep_info_t * info)
static int snd_ctl_shm_pcm_next_device(snd_ctl_t *ctl, int * device)
{
snd_ctl_shm_t *shm = ctl->private;
snd_ctl_shm_ctrl_t *ctrl = shm->ctrl;
volatile snd_ctl_shm_ctrl_t *ctrl = shm->ctrl;
int err;
ctrl->u.device = *device;
ctrl->cmd = SND_CTL_IOCTL_PCM_NEXT_DEVICE;
@ -241,7 +237,7 @@ static int snd_ctl_shm_pcm_next_device(snd_ctl_t *ctl, int * device)
static int snd_ctl_shm_pcm_info(snd_ctl_t *ctl, snd_pcm_info_t * info)
{
snd_ctl_shm_t *shm = ctl->private;
snd_ctl_shm_ctrl_t *ctrl = shm->ctrl;
volatile snd_ctl_shm_ctrl_t *ctrl = shm->ctrl;
int err;
ctrl->u.pcm_info = *info;
ctrl->cmd = SND_CTL_IOCTL_PCM_INFO;
@ -255,7 +251,7 @@ static int snd_ctl_shm_pcm_info(snd_ctl_t *ctl, snd_pcm_info_t * info)
static int snd_ctl_shm_pcm_prefer_subdevice(snd_ctl_t *ctl, int subdev)
{
snd_ctl_shm_t *shm = ctl->private;
snd_ctl_shm_ctrl_t *ctrl = shm->ctrl;
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;
@ -268,7 +264,7 @@ static int snd_ctl_shm_pcm_prefer_subdevice(snd_ctl_t *ctl, int subdev)
static int snd_ctl_shm_rawmidi_next_device(snd_ctl_t *ctl, int * device)
{
snd_ctl_shm_t *shm = ctl->private;
snd_ctl_shm_ctrl_t *ctrl = shm->ctrl;
volatile snd_ctl_shm_ctrl_t *ctrl = shm->ctrl;
int err;
ctrl->u.device = *device;
ctrl->cmd = SND_CTL_IOCTL_RAWMIDI_NEXT_DEVICE;
@ -282,7 +278,7 @@ static int snd_ctl_shm_rawmidi_next_device(snd_ctl_t *ctl, int * device)
static int snd_ctl_shm_rawmidi_info(snd_ctl_t *ctl, snd_rawmidi_info_t * info)
{
snd_ctl_shm_t *shm = ctl->private;
snd_ctl_shm_ctrl_t *ctrl = shm->ctrl;
volatile snd_ctl_shm_ctrl_t *ctrl = shm->ctrl;
int err;
ctrl->u.rawmidi_info = *info;
ctrl->cmd = SND_CTL_IOCTL_RAWMIDI_INFO;
@ -296,7 +292,7 @@ static int snd_ctl_shm_rawmidi_info(snd_ctl_t *ctl, snd_rawmidi_info_t * info)
static int snd_ctl_shm_rawmidi_prefer_subdevice(snd_ctl_t *ctl, int subdev)
{
snd_ctl_shm_t *shm = ctl->private;
snd_ctl_shm_ctrl_t *ctrl = shm->ctrl;
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;
@ -309,7 +305,7 @@ static int snd_ctl_shm_rawmidi_prefer_subdevice(snd_ctl_t *ctl, int subdev)
static int snd_ctl_shm_read(snd_ctl_t *ctl, snd_ctl_event_t *event)
{
snd_ctl_shm_t *shm = ctl->private;
snd_ctl_shm_ctrl_t *ctrl = shm->ctrl;
volatile snd_ctl_shm_ctrl_t *ctrl = shm->ctrl;
int err;
ctrl->u.read = *event;
ctrl->cmd = SND_CTL_IOCTL_READ;

View file

@ -668,10 +668,10 @@ int snd_pcm_open(snd_pcm_t **pcmp, char *name,
err = sscanf(name, "plug:%d,%d", &card, &dev);
if (err == 2)
return snd_pcm_plug_open_hw(pcmp, name, card, dev, -1, stream, mode);
err = sscanf(name, "shm:%256s,%256s", socket, sname);
err = sscanf(name, "shm:%256[^,],%256[^,]", socket, sname);
if (err == 2)
return snd_pcm_shm_open(pcmp, NULL, socket, sname, stream, mode);
err = sscanf(name, "file:%256s,%16s", file, format);
err = sscanf(name, "file:%256[^,],%16[^,]", file, format);
if (err == 2) {
snd_pcm_t *slave;
err = snd_pcm_null_open(&slave, NULL, stream, mode);
@ -679,7 +679,7 @@ int snd_pcm_open(snd_pcm_t **pcmp, char *name,
return err;
return snd_pcm_file_open(pcmp, NULL, file, -1, format, slave, 1);
}
err = sscanf(name, "file:%256s", file);
err = sscanf(name, "file:%256[^,]", file);
if (err == 1) {
snd_pcm_t *slave;
err = snd_pcm_null_open(&slave, NULL, stream, mode);

View file

@ -120,12 +120,8 @@ static int snd_pcm_shm_card(snd_pcm_t *pcm)
{
snd_pcm_shm_t *shm = pcm->private;
volatile snd_pcm_shm_ctrl_t *ctrl = shm->ctrl;
int err;
ctrl->cmd = SND_PCM_IOCTL_CARD;
err = snd_pcm_shm_action(pcm);
if (err < 0)
return err;
return ctrl->u.card;
return snd_pcm_shm_action(pcm);
}
static int snd_pcm_shm_nonblock(snd_pcm_t *pcm ATTRIBUTE_UNUSED, int nonblock ATTRIBUTE_UNUSED)