Date: Mon, 30 Mar 2020 07:00:21 +0000 From: bugzilla-noreply@freebsd.org To: gnome@FreeBSD.org Subject: maintainer-approval requested: [Bug 245156] audio/pulseaudio: parse /dev/sndstat correctly to get device name : [Attachment 212854] Proposed patch (since 516738 revision, v1) Message-ID: <bug-245156-6497-lF1SGFkJte@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
lightside <lightside@gmx.com> has asked freebsd-gnome mailing list <gnome@FreeBSD.org> for maintainer-approval: Bug 245156: audio/pulseaudio: parse /dev/sndstat correctly to get device na= me https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D245156 Attachment 212854: Proposed patch (since 516738 revision, v1) https://bugs.freebsd.org/bugzilla/attachment.cgi?id=3D212854&action=3Dedit --- 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.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-245156-6497-lF1SGFkJte>