Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 30 Mar 2020 07:00:21 +0000
From:      bugzilla-noreply@freebsd.org
To:        gnome@FreeBSD.org
Subject:   [Bug 245156] audio/pulseaudio: parse /dev/sndstat correctly to get device name
Message-ID:  <bug-245156-6497-0bMk0zC6Jv@https.bugs.freebsd.org/bugzilla/>
In-Reply-To: <bug-245156-6497@https.bugs.freebsd.org/bugzilla/>
References:  <bug-245156-6497@https.bugs.freebsd.org/bugzilla/>

next in thread | previous in thread | raw e-mail | index | archive | help
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D245156

lightside <lightside@gmx.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |gnome@FreeBSD.org
 Attachment #212854|                            |maintainer-approval?(gnome@
              Flags|                            |FreeBSD.org)

--- Comment #5 from lightside <lightside@gmx.com> ---
Created attachment 212854
  --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=3D212854&action=
=3Dedit
Proposed patch (since 516738 revision, v1)

I created some testcase:
-8<--
#include <stdio.h>
#include <string.h>

int main() {
        const char *line =3D "pcm4: <Realtek (0x1168) (Rear Analog 5.1/2.0)>
(play/rec) default";
        int device;

        if (sscanf(line, "pcm%i: ", &device) !=3D 1)
                return 0;
        {
                char *k =3D strchr(line, ':');
                k++;
                k +=3D strspn(k, " <");
                char *e =3D strrchr(k, '>');

                if (!e)
                        return 0;

                const size_t len =3D strlen(k) - strlen(e);
                char m[len];
                strncpy(m, k, len);

                printf("pcm%d: %s\n", device, m);
                // pcm4: Realtek (0x1168) (Rear Analog 5.1/2.0)
        }
        {
                char *k =3D strrchr(line, '>');

                if (!k)
                        return 0;

                const size_t len =3D strlen(line) - strlen(k) + 1;
                char m[len];
                strncpy(m, line, len);

                printf("%s\n", m);
                // pcm4: <Realtek (0x1168) (Rear Analog 5.1/2.0)>
        }

        return 0;
}
-->8-

which outputs two variants for "pcm4: <Realtek (0x1168) (Rear Analog 5.1/2.=
0)>
(play/rec) default" line:
-8<--
pcm4: Realtek (0x1168) (Rear Analog 5.1/2.0)
pcm4: <Realtek (0x1168) (Rear Analog 5.1/2.0)>
-->8-

Attached patch for first variant.

--=20
You are receiving this mail because:
You are the assignee for the bug.
You are on the CC list for the bug.=



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-245156-6497-0bMk0zC6Jv>