Lines 10-22
Link Here
|
10 |
|
10 |
|
11 |
static const char* const valid_modargs[] = { |
11 |
static const char* const valid_modargs[] = { |
12 |
"just-one", |
12 |
"just-one", |
13 |
@@ -157,8 +159,7 @@ static int detect_oss(pa_core *c, int ju |
13 |
@@ -157,11 +159,49 @@ static int detect_oss(pa_core *c, int ju |
14 |
continue; |
14 |
continue; |
15 |
|
15 |
|
16 |
} else if (sscanf(line, "pcm%u: ", &device) == 1) { |
16 |
} else if (sscanf(line, "pcm%u: ", &device) == 1) { |
17 |
- /* FreeBSD support, the devices are named /dev/dsp0.0, dsp0.1 and so on */ |
17 |
- /* FreeBSD support, the devices are named /dev/dsp0.0, dsp0.1 and so on */ |
18 |
- pa_snprintf(args, sizeof(args), "device=/dev/dsp%u.0", device); |
18 |
- pa_snprintf(args, sizeof(args), "device=/dev/dsp%u.0", device); |
19 |
+ pa_snprintf(args, sizeof(args), "device=/dev/dsp%u", device); |
19 |
+ int is_sink = 0, is_source = 0; |
|
|
20 |
+ if (pa_endswith(line, "default")) { |
21 |
+ const char *p = strstr(line, "> ("); |
22 |
+ if (p) { |
23 |
+ if (strstr(p, "play")) |
24 |
+ is_sink = 1; |
20 |
|
25 |
|
21 |
if (!pa_module_load(c, "module-oss", args)) |
26 |
- if (!pa_module_load(c, "module-oss", args)) |
|
|
27 |
+ if (strstr(p, "rec")) |
28 |
+ is_source = 1; |
29 |
+ } |
30 |
+ } |
31 |
+ |
32 |
+ pa_snprintf(args, sizeof(args), "device=/dev/dsp%u", device); |
33 |
+ pa_module *m = pa_module_load(c, "module-oss", args); |
34 |
+ |
35 |
+ if (!m) |
22 |
continue; |
36 |
continue; |
|
|
37 |
+ |
38 |
+ if (!c->default_sink && is_sink) { |
39 |
+ uint32_t idx = PA_IDXSET_INVALID; |
40 |
+ pa_sink *s; |
41 |
+ PA_IDXSET_FOREACH(s, c->sinks, idx) { |
42 |
+ if (s->module == m) { |
43 |
+ if (!pa_namereg_set_default_sink(c, s)) |
44 |
+ pa_log_error("failed to set default sink for device: /dev/dsp%u", device); |
45 |
+ |
46 |
+ break; |
47 |
+ } |
48 |
+ } |
49 |
+ } |
50 |
+ |
51 |
+ if (!c->default_source && is_source) { |
52 |
+ uint32_t idx = PA_IDXSET_INVALID; |
53 |
+ pa_source *s; |
54 |
+ PA_IDXSET_FOREACH(s, c->sources, idx) { |
55 |
+ if (s->module == m) { |
56 |
+ if (!pa_namereg_set_default_source(c, s)) |
57 |
+ pa_log_error("failed to set default source for device: /dev/dsp%u", device); |
58 |
+ |
59 |
+ break; |
60 |
+ } |
61 |
+ } |
62 |
+ } |
63 |
} |
64 |
|
65 |
n++; |