int record = 1, playback = 1;
pa_sample_spec ss;
pa_modargs *ma = NULL;
- assert(c && m);
+ char hwdesc[64];
+
+ assert(c);
+ assert(m);
if (!(ma = pa_modargs_new(m->argument, valid_modargs))) {
pa_log(__FILE__": failed to parse module arguments.\n");
if ((fd = pa_oss_open(p = pa_modargs_get_value(ma, "device", DEFAULT_DEVICE), &mode, NULL)) < 0)
goto fail;
+ if (pa_oss_get_hw_description(p, hwdesc, sizeof(hwdesc)) >= 0)
+ pa_log_info(__FILE__": hardware name is '%s'.\n", hwdesc);
+ else
+ hwdesc[0] = 0;
+
pa_log_info(__FILE__": device opened in %s mode.\n", mode == O_WRONLY ? "O_WRONLY" : (mode == O_RDONLY ? "O_RDONLY" : "O_RDWR"));
if (nfrags >= 2 && frag_size >= 1)
u->source->notify = source_notify_cb;
u->source->get_latency = source_get_latency_cb;
pa_source_set_owner(u->source, m);
- u->source->description = pa_sprintf_malloc("Open Sound System PCM on '%s'", p);
+ u->source->description = pa_sprintf_malloc("Open Sound System PCM on '%s'%s%s%s",
+ p,
+ hwdesc[0] ? " (" : "",
+ hwdesc[0] ? hwdesc : "",
+ hwdesc[0] ? ")" : "");
} else
u->source = NULL;
u->sink->set_hw_volume = sink_set_hw_volume;
u->sink->userdata = u;
pa_sink_set_owner(u->sink, m);
- u->sink->description = pa_sprintf_malloc("Open Sound System PCM on '%s'", p);
+ u->sink->description = pa_sprintf_malloc("Open Sound System PCM on '%s'%s%s%s",
+ p,
+ hwdesc[0] ? " (" : "",
+ hwdesc[0] ? hwdesc : "",
+ hwdesc[0] ? ")" : "");
} else
u->sink = NULL;
pa_log_debug(__FILE__": Wrote mixer settings: %s\n", pa_cvolume_snprint(cv, sizeof(cv), volume));
return 0;
}
+
+int pa_oss_get_hw_description(const char *dev, char *name, size_t l) {
+ FILE *f;
+ const char *e = NULL;
+ int n, r = -1;
+ int b = 0;
+
+ if (strncmp(dev, "/dev/dsp", 8) == 0)
+ e = dev+8;
+ else if (strncmp(dev, "/dev/adsp", 9) == 0)
+ e = dev+9;
+ else
+ return -1;
+
+ if (*e == 0)
+ n = 0;
+ else if (*e >= '0' && *e <= '9' && *(e+1) == 0)
+ n = *e - '0';
+ else
+ return -1;
+
+ if (!(f = fopen("/dev/sndstat", "r")) &&
+ !(f = fopen("/proc/sndstat", "r")) &&
+ !(f = fopen("/proc/asound/oss/sndstat", "r"))) {
+
+ if (errno != ENOENT)
+ pa_log_warn(__FILE__": failed to open OSS sndstat device: %s\n", strerror(errno));
+
+ return -1;
+ }
+
+ while (!feof(f)) {
+ char line[64];
+ int device;
+
+ if (!fgets(line, sizeof(line), f))
+ break;
+
+ line[strcspn(line, "\r\n")] = 0;
+
+ if (!b) {
+ b = strcmp(line, "Audio devices:") == 0;
+ continue;
+ }
+
+ if (line[0] == 0)
+ break;
+
+ if (sscanf(line, "%i: ", &device) != 1)
+ continue;
+
+ if (device == n) {
+ char *k = strchr(line, ':');
+ assert(k);
+ k++;
+ k += strspn(k, " ");
+
+ if (pa_endswith(k, " (DUPLEX)"))
+ k[strlen(k)-9] = 0;
+
+ pa_strlcpy(name, k, l);
+ r = 0;
+ break;
+ }
+ }
+
+ fclose(f);
+ return r;
+}
int pa_oss_get_volume(int fd, const pa_sample_spec *ss, pa_cvolume *volume);
int pa_oss_set_volume(int fd, const pa_sample_spec *ss, const pa_cvolume *volume);
+int pa_oss_get_hw_description(const char *dev, char *name, size_t l);
+
#endif