Ticket #544: patch-src_modules_module-hal-detect.2.c

File patch-src_modules_module-hal-detect.2.c, 2.4 KB (added by cmt, 3 years ago)

adds option "subdevs" when compiled HAVE_OSS

Line 
1--- src/modules/module-hal-detect.c.orig    2009-04-18 11:29:22.000000000 +0200
2+++ src/modules/module-hal-detect.c 2009-04-22 21:18:56.000000000 +0200
3@@ -57,12 +57,14 @@
4 PA_MODULE_LOAD_ONCE(TRUE);
5 #if defined(HAVE_ALSA) && defined(HAVE_OSS)
6 PA_MODULE_USAGE("api=<alsa or oss> "
7-                "tsched=<enable system timer based scheduling mode?>");
8+                "tsched=<enable system timer based scheduling mode?>"
9+                "subdevs=<init all subdevices>");
10 #elif defined(HAVE_ALSA)
11 PA_MODULE_USAGE("api=<alsa> "
12                 "tsched=<enable system timer based scheduling mode?>");
13 #elif defined(HAVE_OSS)
14-PA_MODULE_USAGE("api=<oss>");
15+PA_MODULE_USAGE("api=<oss>"
16+                "subdevs=<init all subdevices>");
17 #endif
18 
19 struct device {
20@@ -81,6 +83,9 @@
21 #ifdef HAVE_ALSA
22     pa_bool_t use_tsched;
23 #endif
24+#ifdef HAVE_OSS
25+    pa_bool_t init_subdevs;
26+#endif
27 };
28 
29 #define CAPABILITY_ALSA "alsa"
30@@ -91,6 +96,9 @@
31 #ifdef HAVE_ALSA
32     "tsched",
33 #endif
34+#ifdef HAVE_OSS
35+    "subdevs",
36+#endif
37     NULL
38 };
39 
40@@ -263,7 +271,7 @@
41 
42 #ifdef HAVE_OSS
43 
44-static pa_bool_t hal_oss_device_is_pcm(LibHalContext *context, const char *udi) {
45+static pa_bool_t hal_oss_device_is_pcm(LibHalContext *context, const char *udi, pa_bool_t init_subdevices) {
46     char *class = NULL, *dev = NULL, *e;
47     int device;
48     pa_bool_t r = FALSE;
49@@ -293,7 +301,7 @@
50 
51     /* We only care for the main device */
52     device = libhal_device_get_property_int(context, udi, "oss.device", &error);
53-    if (dbus_error_is_set(&error) || device != 0)
54+    if (dbus_error_is_set(&error) || (device != 0 && init_subdevices == FALSE))
55         goto finish;
56 
57     r = TRUE;
58@@ -323,7 +331,7 @@
59     pa_assert(d);
60 
61     /* We only care for OSS PCM devices */
62-    if (!hal_oss_device_is_pcm(u->context, udi))
63+    if (!hal_oss_device_is_pcm(u->context, udi, u->init_subdevs))
64         goto fail;
65 
66     /* We store only one entry per card, hence we look for the originating device */
67@@ -762,6 +770,13 @@
68         goto fail;
69     }
70 
71+#ifdef HAVE_OSS
72+    if (pa_modargs_get_value_boolean(ma, "subdevs", &u->init_subdevs) < 0) {
73+        pa_log("Failed to parse subdevs argument.");
74+        goto fail;
75+    }
76+#endif
77+
78     if (!(u->connection = pa_dbus_bus_get(m->core, DBUS_BUS_SYSTEM, &error)) || dbus_error_is_set(&error)) {
79         pa_log_error("Unable to contact DBUS system bus: %s: %s", error.name, error.message);
80         goto fail;