[BACK]Return to fdpass.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / sndiod

Diff for /src/usr.bin/sndiod/fdpass.c between version 1.7 and 1.8

version 1.7, 2019/09/21 04:42:46 version 1.8, 2020/01/23 05:40:09
Line 35 
Line 35 
 #define FDPASS_RETURN           3       /* return after above commands */  #define FDPASS_RETURN           3       /* return after above commands */
         unsigned int cmd;               /* one of above */          unsigned int cmd;               /* one of above */
         unsigned int num;               /* audio device or midi port number */          unsigned int num;               /* audio device or midi port number */
           unsigned int idx;               /* index in the path list */
         unsigned int mode;              /* SIO_PLAY, SIO_REC, MIO_IN, ... */          unsigned int mode;              /* SIO_PLAY, SIO_REC, MIO_IN, ... */
 };  };
   
Line 75 
Line 76 
 }  }
   
 static int  static int
 fdpass_send(struct fdpass *f, int cmd, int num, int mode, int fd)  fdpass_send(struct fdpass *f, int cmd, int num, int idx, int mode, int fd)
 {  {
         struct fdpass_msg data;          struct fdpass_msg data;
         struct msghdr msg;          struct msghdr msg;
Line 89 
Line 90 
   
         data.cmd = cmd;          data.cmd = cmd;
         data.num = num;          data.num = num;
           data.idx = idx;
         data.mode = mode;          data.mode = mode;
         iov.iov_base = &data;          iov.iov_base = &data;
         iov.iov_len = sizeof(struct fdpass_msg);          iov.iov_len = sizeof(struct fdpass_msg);
Line 128 
Line 130 
                 log_puti(cmd);                  log_puti(cmd);
                 log_puts(", num = ");                  log_puts(", num = ");
                 log_puti(num);                  log_puti(num);
                   log_puts(", idx = ");
                   log_puti(idx);
                 log_puts(", mode = ");                  log_puts(", mode = ");
                 log_puti(mode);                  log_puti(mode);
                 log_puts(", fd = ");                  log_puts(", fd = ");
Line 141 
Line 145 
 }  }
   
 static int  static int
 fdpass_recv(struct fdpass *f, int *cmd, int *num, int *mode, int *fd)  fdpass_recv(struct fdpass *f, int *cmd, int *num, int *idx, int *mode, int *fd)
 {  {
         struct fdpass_msg data;          struct fdpass_msg data;
         struct msghdr msg;          struct msghdr msg;
Line 212 
Line 216 
         }          }
         *cmd = data.cmd;          *cmd = data.cmd;
         *num = data.num;          *num = data.num;
           *idx = data.idx;
         *mode = data.mode;          *mode = data.mode;
 #ifdef DEBUG  #ifdef DEBUG
         if (log_level >= 3) {          if (log_level >= 3) {
Line 220 
Line 225 
                 log_puti(*cmd);                  log_puti(*cmd);
                 log_puts(", num = ");                  log_puts(", num = ");
                 log_puti(*num);                  log_puti(*num);
                   log_puts(", idx = ");
                   log_puti(*idx);
                 log_puts(", mode = ");                  log_puts(", mode = ");
                 log_puti(*mode);                  log_puti(*mode);
                 log_puts(", fd = ");                  log_puts(", fd = ");
Line 235 
Line 242 
 {  {
         int cmd, unused;          int cmd, unused;
   
         if (!fdpass_recv(fdpass_peer, &cmd, &unused, &unused, retfd))          if (!fdpass_recv(fdpass_peer, &cmd, &unused, &unused, &unused, retfd))
                 return 0;                  return 0;
         if (cmd != FDPASS_RETURN) {          if (cmd != FDPASS_RETURN) {
                 if (log_level >= 1) {                  if (log_level >= 1) {
Line 249 
Line 256 
 }  }
   
 struct sio_hdl *  struct sio_hdl *
 fdpass_sio_open(int num, unsigned int mode)  fdpass_sio_open(int num, int idx, unsigned int mode)
 {  {
         int fd;          int fd;
   
         if (fdpass_peer == NULL)          if (fdpass_peer == NULL)
                 return NULL;                  return NULL;
         if (!fdpass_send(fdpass_peer, FDPASS_OPEN_SND, num, mode, -1))          if (!fdpass_send(fdpass_peer, FDPASS_OPEN_SND, num, idx, mode, -1))
                 return NULL;                  return NULL;
         if (!fdpass_waitret(fdpass_peer, &fd))          if (!fdpass_waitret(fdpass_peer, &fd))
                 return NULL;                  return NULL;
Line 265 
Line 272 
 }  }
   
 struct mio_hdl *  struct mio_hdl *
 fdpass_mio_open(int num, unsigned int mode)  fdpass_mio_open(int num, int idx, unsigned int mode)
 {  {
         int fd;          int fd;
   
         if (fdpass_peer == NULL)          if (fdpass_peer == NULL)
                 return NULL;                  return NULL;
         if (!fdpass_send(fdpass_peer, FDPASS_OPEN_MIDI, num, mode, -1))          if (!fdpass_send(fdpass_peer, FDPASS_OPEN_MIDI, num, idx, mode, -1))
                 return NULL;                  return NULL;
         if (!fdpass_waitret(fdpass_peer, &fd))          if (!fdpass_waitret(fdpass_peer, &fd))
                 return NULL;                  return NULL;
Line 296 
Line 303 
 void  void
 fdpass_in_helper(void *arg)  fdpass_in_helper(void *arg)
 {  {
         int cmd, num, mode, fd;          int cmd, num, idx, mode, fd;
         struct fdpass *f = arg;          struct fdpass *f = arg;
         struct dev *d;          struct dev *d;
         struct port *p;          struct port *p;
         struct name *path;          char *path;
   
         if (!fdpass_recv(f, &cmd, &num, &mode, &fd))          if (!fdpass_recv(f, &cmd, &num, &idx, &mode, &fd))
                 return;                  return;
         switch (cmd) {          switch (cmd) {
         case FDPASS_OPEN_SND:          case FDPASS_OPEN_SND:
Line 315 
Line 322 
                         fdpass_close(f);                          fdpass_close(f);
                         return;                          return;
                 }                  }
                 for (path = d->path_list; path != NULL; path = path->next) {                  path = namelist_byindex(&d->path_list, idx);
                         fd = sio_sun_getfd(path->str, mode, 1);                  if (path == NULL) {
                         if (fd != -1)                          fdpass_close(f);
                                 break;                          return;
                 }                  }
                   fd = sio_sun_getfd(path, mode, 1);
                 break;                  break;
         case FDPASS_OPEN_MIDI:          case FDPASS_OPEN_MIDI:
                 p = port_bynum(num);                  p = port_bynum(num);
Line 331 
Line 339 
                         fdpass_close(f);                          fdpass_close(f);
                         return;                          return;
                 }                  }
                 for (path = p->path_list; path != NULL; path = path->next) {                  path = namelist_byindex(&p->path_list, idx);
                         fd = mio_rmidi_getfd(path->str, mode, 1);                  if (path == NULL) {
                         if (fd != -1)                          fdpass_close(f);
                                 break;                          return;
                 }                  }
                   fd = mio_rmidi_getfd(path, mode, 1);
                 break;                  break;
         default:          default:
                 fdpass_close(f);                  fdpass_close(f);
                 return;                  return;
         }          }
         fdpass_send(f, FDPASS_RETURN, 0, 0, fd);          fdpass_send(f, FDPASS_RETURN, 0, 0, 0, fd);
 }  }
   
 void  void

Legend:
Removed from v.1.7  
changed lines
  Added in v.1.8