FreeBSD Bugzilla – Attachment 228708 Details for
Bug 245156
audio/pulseaudio: parse /dev/sndstat correctly to get device name
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Proposed patch (since bfcd467d8f commit)
pulseaudio.diff (text/plain), 6.20 KB, created by
lightside
on 2021-10-15 02:17:41 UTC
(
hide
)
Description:
Proposed patch (since bfcd467d8f commit)
Filename:
MIME Type:
Creator:
lightside
Created:
2021-10-15 02:17:41 UTC
Size:
6.20 KB
patch
obsolete
>--- files/patch-src_modules_oss_oss-util.c >+++ files/patch-src_modules_oss_oss-util.c >@@ -1,9 +1,13 @@ >-Support 24bit audio see Comment 6 of >-https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=198567 >+Based on the following patches: >+https://cgit.freebsd.org/ports/commit/audio/pulseaudio/files/patch-src_modules_oss-util.c?id=4ba786e49ded8d06cd62b603daf9951de5f88f1d >+ >+Upstream patches from 14.2 to 15.0 version: >+https://github.com/pulseaudio/pulseaudio/commit/ef8fa7c99752e0c404039a4c0f0c188d7033c431#diff-6c30591ff7b76f1d351f192894d3a1c2ade897dfe3f077af6cea7108ad1f6dbd >+https://github.com/pulseaudio/pulseaudio/commit/0f70a6f519fa0c499d1bbc194ea8be5195033c3e > > --- src/modules/oss/oss-util.c.orig 2018-07-13 19:06:14 UTC > +++ src/modules/oss/oss-util.c >-@@ -39,6 +39,22 @@ >+@@ -39,7 +39,24 @@ > > #include "oss-util.h" > >@@ -24,66 +28,162 @@ > +#endif > + > int pa_oss_open(const char *device, int *mode, int* pcaps) { >++ static const int nonblock_io = 1; > int fd = -1; > int caps; >-@@ -164,8 +180,8 @@ int pa_oss_auto_format(int fd, pa_sample >+ char *t; >+@@ -89,6 +106,10 @@ >+ } >+ >+ success: >++ if (ioctl(fd, FIONBIO, &nonblock_io) < 0) { >++ pa_log("FIONBIO: %s", pa_cstrerror(errno)); >++ goto fail; >++ } >+ >+ t = pa_sprintf_malloc( >+ "%s%s%s%s%s%s%s%s%s%s%s%s%s%s", >+@@ -164,8 +185,13 @@ > [PA_SAMPLE_FLOAT32BE] = AFMT_QUERY, /* not supported */ > [PA_SAMPLE_S32LE] = AFMT_QUERY, /* not supported */ > [PA_SAMPLE_S32BE] = AFMT_QUERY, /* not supported */ >-- [PA_SAMPLE_S24LE] = AFMT_QUERY, /* not supported */ >-- [PA_SAMPLE_S24BE] = AFMT_QUERY, /* not supported */ >++#if defined(AFMT_S24_LE) && defined(AFMT_S24_BE) > + [PA_SAMPLE_S24LE] = AFMT_S24_LE, > + [PA_SAMPLE_S24BE] = AFMT_S24_BE, >++#else >+ [PA_SAMPLE_S24LE] = AFMT_QUERY, /* not supported */ >+ [PA_SAMPLE_S24BE] = AFMT_QUERY, /* not supported */ >++#endif > [PA_SAMPLE_S24_32LE] = AFMT_QUERY, /* not supported */ > [PA_SAMPLE_S24_32BE] = AFMT_QUERY, /* not supported */ > }; >-@@ -348,7 +364,7 @@ int pa_oss_get_hw_description(const char >+@@ -290,41 +316,35 @@ >+ } >+ >+ static int get_device_number(const char *dev) { >+- const char *p, *e; >++ const char *p; >++ const char *e; >+ char *rp = NULL; >+- int r; >++ int r = -1; >+ >+ if (!(p = rp = pa_readlink(dev))) { >+-#ifdef ENOLINK >+- if (errno != EINVAL && errno != ENOLINK) { >+-#else >+- if (errno != EINVAL) { >+-#endif >+- r = -1; >+- goto finish; >+- } >+- >++ if (errno != EINVAL && errno != ENOLINK) >++ return -2; >+ p = dev; >+ } >+ >+- if ((e = strrchr(p, '/'))) >+- p = e+1; >+- >+- if (p == 0) { >+- r = 0; >+- goto finish; >+- } >+- >+- p = strchr(p, 0) -1; >+- >+- if (*p >= '0' && *p <= '9') { >+- r = *p - '0'; >+- goto finish; >++ /* find the last forward slash */ >++ while ((e = strrchr(p, '/'))) >++ p = e + 1; >++ >++ /* collect unit number at end, if any */ >++ while (*p) { >++ if (*p >= '0' && *p <= '9') { >++ if (r < 0) >++ r = 0; >++ else >++ r *= 10; >++ r += *p - '0'; >++ } else { >++ r = -1; >++ } >++ p++; >+ } >+ >+- r = -1; >+- >+-finish: >+ pa_xfree(rp); >+ return r; >+ } >+@@ -334,7 +354,7 @@ >+ int n, r = -1; >+ int b = 0; >+ >+- if ((n = get_device_number(dev)) < 0) >++ if ((n = get_device_number(dev)) == -2) >+ return -1; >+ >+ if (!(f = pa_fopen_cloexec("/dev/sndstat", "r")) && >+@@ -348,8 +368,8 @@ > } > > while (!feof(f)) { > - char line[64]; >-+ char line[1024]; >- int device; >+- int device; >++ char line[1024] = { 0 }; >++ unsigned device; > > if (!fgets(line, sizeof(line), f)) >-@@ -357,14 +373,22 @@ int pa_oss_get_hw_description(const char >+ break; >+@@ -357,26 +377,29 @@ > line[strcspn(line, "\r\n")] = 0; > > if (!b) { >-+#ifdef __FreeBSD__ >-+ b = pa_streq(line, "Installed devices:"); >-+#else >- b = pa_streq(line, "Audio devices:"); >-+#endif >+- b = pa_streq(line, "Audio devices:"); >++ b = pa_streq(line, "Audio devices:") || pa_streq(line, "Installed devices:"); > continue; > } > > if (line[0] == 0) > break; > >-+#ifdef __FreeBSD__ >-+ if (sscanf(line, "pcm%i: ", &device) != 1) >-+#else >- if (sscanf(line, "%i: ", &device) != 1) >-+#endif >+- if (sscanf(line, "%i: ", &device) != 1) >++ if (sscanf(line, "%u: ", &device) != 1 && sscanf(line, "pcm%u: ", &device) != 1) > continue; > > if (device == n) { >-@@ -376,7 +400,16 @@ int pa_oss_get_hw_description(const char >+ char *k = strchr(line, ':'); >+ pa_assert(k); >+ k++; >+- k += strspn(k, " "); >++ k += strspn(k, " <"); >+ > if (pa_endswith(k, " (DUPLEX)")) > k[strlen(k)-9] = 0; > > - pa_strlcpy(name, k, l); >-+ if (*k == '<') { >-+ char *e = strrchr(k, '>'); >++ k[strcspn(k, ">")] = 0; > + >-+ if (e) { >-+ *e = 0; >-+ ++k; >-+ } >-+ } > + // Include the number to disambiguate devices with the same name >-+ pa_snprintf(name, l, "%d: %s", device, k); >++ pa_snprintf(name, l, "%u - %s", device, k); > r = 0; > break; > } >+@@ -400,10 +423,10 @@ >+ char *fn; >+ int fd; >+ >+- if ((n = get_device_number(device)) < 0) >++ if ((n = get_device_number(device)) == -2) >+ return -1; >+ >+- if (n == 0) >++ if (n == -1) >+ if ((fd = open_mixer("/dev/mixer")) >= 0) >+ return fd; >+ >--- Makefile >+++ Makefile >@@ -5,7 +5,7 @@ > > PORTNAME= pulseaudio > DISTVERSION= 14.2 >-PORTREVISION= 3 >+PORTREVISION= 4 > CATEGORIES= audio > MASTER_SITES= https://freedesktop.org/software/pulseaudio/releases/ >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Flags:
lightside
:
maintainer-approval?
(
desktop
)
Actions:
View
|
Diff
Attachments on
bug 245156
:
212817
|
212838
|
212854
|
212855
|
212875
|
212876
|
212877
|
212878
|
213004
|
213005
|
213006
|
213025
|
213026
|
213050
|
213051
|
213052
|
228663
| 228708