Allow -current libsndio to connect to old sndiod servers
authorratchov <ratchov@openbsd.org>
Sun, 7 Nov 2021 20:51:47 +0000 (20:51 +0000)
committerratchov <ratchov@openbsd.org>
Sun, 7 Nov 2021 20:51:47 +0000 (20:51 +0000)
Recent sndio device naming change is missing the proper compatibility
bits for this case. Found and fixed by bluhm@ and tweaks from me.

ok bluhm

lib/libsndio/aucat.c

index 6d7a154..1e48786 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: aucat.c,v 1.78 2021/11/01 14:43:24 ratchov Exp $      */
+/*     $OpenBSD: aucat.c,v 1.79 2021/11/07 20:51:47 ratchov Exp $      */
 /*
  * Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org>
  *
@@ -444,10 +444,22 @@ _aucat_open(struct aucat *hdl, const char *str, unsigned int mode)
        }
        p++;
        if (type == 0) {
-               devnum = AMSG_NODEV;
-               p = parsestr(p, opt, AMSG_OPTMAX);
-               if (p == NULL)
-                       return 0;
+               if (*p < '0' || *p > '9') {
+                       devnum = AMSG_NODEV;
+                       p = parsestr(p, opt, AMSG_OPTMAX);
+                       if (p == NULL)
+                               return 0;
+               } else {
+                       p = _sndio_parsenum(p, &devnum, 15);
+                       if (p == NULL)
+                               return 0;
+                       if (*p == '.') {
+                               p = parsestr(++p, opt, AMSG_OPTMAX);
+                               if (p == NULL)
+                                       return 0;
+                       } else
+                               strlcpy(opt, "default", AMSG_OPTMAX);
+               }
        } else {
                p = _sndio_parsenum(p, &devnum, 15);
                if (p == NULL)