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,45 @@ 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 |
+ pa_snprintf(args, sizeof(args), "device=/dev/dsp%u", device); |
|
|
20 |
+ pa_module *m = pa_module_load(c, "module-oss", args); |
20 |
|
21 |
|
21 |
if (!pa_module_load(c, "module-oss", args)) |
22 |
- if (!pa_module_load(c, "module-oss", args)) |
|
|
23 |
+ if (!m) |
24 |
+ continue; |
25 |
+ |
26 |
+ if (!pa_endswith(line, "default")) |
22 |
continue; |
27 |
continue; |
|
|
28 |
+ |
29 |
+ const char *p = strrchr(line, '>'); |
30 |
+ |
31 |
+ if (!p) |
32 |
+ continue; |
33 |
+ |
34 |
+ if (!c->default_sink && strstr(p, "play")) { |
35 |
+ uint32_t idx = PA_IDXSET_INVALID; |
36 |
+ pa_sink *s; |
37 |
+ PA_IDXSET_FOREACH(s, c->sinks, idx) { |
38 |
+ if (s->module == m) { |
39 |
+ if (!pa_namereg_set_default_sink(c, s)) |
40 |
+ pa_log_error("failed to set default sink for device: /dev/dsp%u", device); |
41 |
+ |
42 |
+ break; |
43 |
+ } |
44 |
+ } |
45 |
+ } |
46 |
+ |
47 |
+ if (!c->default_source && strstr(p, "rec")) { |
48 |
+ uint32_t idx = PA_IDXSET_INVALID; |
49 |
+ pa_source *s; |
50 |
+ PA_IDXSET_FOREACH(s, c->sources, idx) { |
51 |
+ if (s->module == m) { |
52 |
+ if (!pa_namereg_set_default_source(c, s)) |
53 |
+ pa_log_error("failed to set default source for device: /dev/dsp%u", device); |
54 |
+ |
55 |
+ break; |
56 |
+ } |
57 |
+ } |
58 |
+ } |
59 |
} |
60 |
|
61 |
n++; |