Commit 94a78106 authored by myfreeweb's avatar myfreeweb

oss: parse device names correctly on FreeBSD

This fixes devices being named just "/dev/dspN" instead of actual
soundcard names.

Loosely based on patch by lightside <lightside@gmx.com>.

ref: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=245156
parent f6a3036e
This commit is part of merge request !277. Comments created here will be created in the context of that merge request.
......@@ -352,7 +352,7 @@ int pa_oss_get_hw_description(const char *dev, char *name, size_t l) {
}
while (!feof(f)) {
char line[64];
char line[1024] = { 0 };
int device;
if (!fgets(line, sizeof(line), f))
......@@ -361,26 +361,37 @@ int pa_oss_get_hw_description(const char *dev, char *name, size_t l) {
line[strcspn(line, "\r\n")] = 0;
if (!b) {
#ifdef __FreeBSD__
b = pa_streq(line, "Installed devices:");
#else
b = pa_streq(line, "Audio devices:");
#endif
continue;
}
if (line[0] == 0)
break;
#ifdef __FreeBSD__
if (sscanf(line, "pcm%i: ", &device) != 1)
#else
if (sscanf(line, "%i: ", &device) != 1)
#endif
continue;
if (device == n) {
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);
k[strcspn(k, ">")] = 0;
// Include the number to disambiguate devices with the same name
pa_snprintf(name, l, "%d - %s", device, k);
r = 0;
break;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment