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

Diff for /src/usr.bin/sndiod/sndiod.c between version 1.35 and 1.36

version 1.35, 2019/06/29 21:23:18 version 1.36, 2019/09/21 04:42:46
Line 93 
Line 93 
 #endif  #endif
   
 void sigint(int);  void sigint(int);
   void sighup(int);
 void opt_ch(int *, int *);  void opt_ch(int *, int *);
 void opt_enc(struct aparams *);  void opt_enc(struct aparams *);
 int opt_mmc(void);  int opt_mmc(void);
Line 109 
Line 110 
     int, int, int, int, int, int, int, int);      int, int, int, int, int, int, int, int);
   
 unsigned int log_level = 0;  unsigned int log_level = 0;
 volatile sig_atomic_t quit_flag = 0;  volatile sig_atomic_t quit_flag = 0, reopen_flag = 0;
   
 char usagestr[] = "usage: sndiod [-d] [-a flag] [-b nframes] "  char usagestr[] = "usage: sndiod [-d] [-a flag] [-b nframes] "
     "[-C min:max] [-c min:max] [-e enc]\n\t"      "[-C min:max] [-c min:max]\n\t"
     "[-f device] [-j flag] [-L addr] [-m mode] [-q port] [-r rate]\n\t"      "[-e enc] [-F device] [-f device] [-j flag] [-L addr] [-m mode]\n\t"
     "[-s name] [-t mode] [-U unit] [-v volume] [-w flag] [-z nframes]\n";      "[-Q port] [-q port] [-r rate] [-s name] [-t mode] [-U unit]\n\t"
       "[-v volume] [-w flag] [-z nframes]\n";
   
 /*  /*
  * SIGINT handler, it raises the quit flag. If the flag is already set,   * SIGINT handler, it raises the quit flag. If the flag is already set,
Line 129 
Line 131 
         quit_flag = 1;          quit_flag = 1;
 }  }
   
   /*
    * SIGHUP handler, it raises the reopen flag, which requests devices
    * to be reopened.
    */
 void  void
   sighup(int s)
   {
           reopen_flag = 1;
   }
   
   void
 opt_ch(int *rcmin, int *rcmax)  opt_ch(int *rcmin, int *rcmax)
 {  {
         char *next, *end;          char *next, *end;
Line 231 
Line 243 
         struct sigaction sa;          struct sigaction sa;
   
         quit_flag = 0;          quit_flag = 0;
           reopen_flag = 0;
         sigfillset(&sa.sa_mask);          sigfillset(&sa.sa_mask);
         sa.sa_flags = SA_RESTART;          sa.sa_flags = SA_RESTART;
         sa.sa_handler = sigint;          sa.sa_handler = sigint;
Line 238 
Line 251 
                 err(1, "sigaction(int) failed");                  err(1, "sigaction(int) failed");
         if (sigaction(SIGTERM, &sa, NULL) == -1)          if (sigaction(SIGTERM, &sa, NULL) == -1)
                 err(1, "sigaction(term) failed");                  err(1, "sigaction(term) failed");
           sa.sa_handler = sighup;
         if (sigaction(SIGHUP, &sa, NULL) == -1)          if (sigaction(SIGHUP, &sa, NULL) == -1)
                 err(1, "sigaction(hup) failed");                  err(1, "sigaction(hup) failed");
 }  }
Line 294 
Line 308 
         struct dev *d;          struct dev *d;
   
         for (d = dev_list; d != NULL; d = d->next) {          for (d = dev_list; d != NULL; d = d->next) {
                 if (strcmp(d->path, path) == 0)                  if (d->path_list->next == NULL &&
                       strcmp(d->path_list->str, path) == 0)
                         return d;                          return d;
         }          }
         if (!bufsz && !round) {          if (!bufsz && !round) {
Line 316 
Line 331 
         struct port *c;          struct port *c;
   
         for (c = port_list; c != NULL; c = c->next) {          for (c = port_list; c != NULL; c = c->next) {
                 if (strcmp(c->path, path) == 0)                  if (c->path_list->next == NULL &&
                       strcmp(c->path_list->str, path) == 0)
                         return c;                          return c;
         }          }
         c = port_new(path, MODE_MIDIMASK, hold);          c = port_new(path, MODE_MIDIMASK, hold);
Line 361 
Line 377 
         struct dev *d;          struct dev *d;
         struct port *p;          struct port *p;
         struct passwd *pw;          struct passwd *pw;
           struct name *n;
         int s[2];          int s[2];
         pid_t pid;          pid_t pid;
   
Line 395 
Line 412 
                             setresuid(pw->pw_uid, pw->pw_uid, pw->pw_uid))                              setresuid(pw->pw_uid, pw->pw_uid, pw->pw_uid))
                                 err(1, "cannot drop privileges");                                  err(1, "cannot drop privileges");
                 }                  }
                 for (d = dev_list; d != NULL; d = d->next)                  for (d = dev_list; d != NULL; d = d->next) {
                         dounveil(d->path, "rsnd/", "/dev/audio");                          for (n = d->path_list; n != NULL; n = n->next)
                 for (p = port_list; p != NULL; p = p->next)                                  dounveil(n->str, "rsnd/", "/dev/audio");
                         dounveil(p->path, "rmidi/", "/dev/rmidi");                  }
                   for (p = port_list; p != NULL; p = p->next) {
                           for (n = p->path_list; n != NULL; n = n->next)
                                   dounveil(n->str, "rmidi/", "/dev/rmidi");
                   }
                 if (pledge("stdio sendfd rpath wpath", NULL) == -1)                  if (pledge("stdio sendfd rpath wpath", NULL) == -1)
                         err(1, "pledge");                          err(1, "pledge");
                 while (file_poll())                  while (file_poll())
Line 461 
Line 482 
         mode = MODE_PLAY | MODE_REC;          mode = MODE_PLAY | MODE_REC;
         tcpaddr_list = NULL;          tcpaddr_list = NULL;
   
         while ((c = getopt(argc, argv, "a:b:c:C:de:f:j:L:m:q:r:s:t:U:v:w:x:z:")) != -1) {          while ((c = getopt(argc, argv,
               "a:b:c:C:de:F:f:j:L:m:Q:q:r:s:t:U:v:w:x:z:")) != -1) {
                 switch (c) {                  switch (c) {
                 case 'd':                  case 'd':
                         log_level++;                          log_level++;
Line 518 
Line 540 
                 case 'q':                  case 'q':
                         mkport(optarg, hold);                          mkport(optarg, hold);
                         break;                          break;
                   case 'Q':
                           if (port_list == NULL)
                                   errx(1, "-Q %s: no ports defined", optarg);
                           namelist_add(&port_list->path_list, optarg);
                           break;
                 case 'a':                  case 'a':
                         hold = opt_onoff();                          hold = opt_onoff();
                         break;                          break;
Line 538 
Line 565 
                         mkdev(optarg, &par, 0, bufsz, round,                          mkdev(optarg, &par, 0, bufsz, round,
                             rate, hold, autovol);                              rate, hold, autovol);
                         break;                          break;
                   case 'F':
                           if (dev_list == NULL)
                                   errx(1, "-F %s: no devices defined", optarg);
                           namelist_add(&dev_list->path_list, optarg);
                           break;
                 default:                  default:
                         fputs(usagestr, stderr);                          fputs(usagestr, stderr);
                         return 1;                          return 1;
Line 617 
Line 649 
         for (;;) {          for (;;) {
                 if (quit_flag)                  if (quit_flag)
                         break;                          break;
                   if (reopen_flag) {
                           reopen_flag = 0;
                           for (d = dev_list; d != NULL; d = d->next)
                                   dev_reopen(d);
                           for (p = port_list; p != NULL; p = p->next)
                                   port_reopen(p);
                   }
                 if (!fdpass_peer)                  if (!fdpass_peer)
                         break;                          break;
                 if (!file_poll())                  if (!file_poll())

Legend:
Removed from v.1.35  
changed lines
  Added in v.1.36