[pulseaudio-commits] r1440 - /trunk/src/modules/module-hal-detect.c

svnmailer-noreply at 0pointer.de svnmailer-noreply at 0pointer.de
Tue May 22 16:38:23 PDT 2007


Author: lennart
Date: Wed May 23 01:38:22 2007
New Revision: 1440

URL: http://0pointer.de/cgi-bin/viewcvs.cgi?rev=3D1440&root=3Dpulseaudio&vi=
ew=3Drev
Log:
Fix build and only load OSS xor ALSA modules if both are available

Modified:
    trunk/src/modules/module-hal-detect.c

Modified: trunk/src/modules/module-hal-detect.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/trunk/src/modules/module-hal-de=
tect.c?rev=3D1440&root=3Dpulseaudio&r1=3D1439&r2=3D1440&view=3Ddiff
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- trunk/src/modules/module-hal-detect.c (original)
+++ trunk/src/modules/module-hal-detect.c Wed May 23 01:38:22 2007
@@ -85,6 +85,9 @@
     capability_t capability;
     pa_dbus_connection *conn;
     pa_hashmap *devices;
+#if defined(HAVE_ALSA) && defined(HAVE_OSS)
+    int use_oss;
+#endif    =

 };
 =

 struct timerdata {
@@ -185,6 +188,8 @@
         snprintf(args, sizeof(args), "device=3Dhw:%u source_name=3Dalsa_in=
put.%s", card, strip_udi(udi));
     }
 =

+    pa_log_debug("Loading %s with arguments '%s'", module_name, args);
+
     return pa_module_load(u->core, module_name, args);
 }
 =

@@ -242,6 +247,8 @@
     snprintf(args, sizeof(args), "device=3D%s sink_name=3Doss_output.%s so=
urce_name=3Doss_input.%s", device, strip_udi(udi), strip_udi(udi));
     libhal_free_string(device);
 =

+    pa_log_debug("Loading module-oss with arguments '%s'", args);
+
     return pa_module_load(u->core, "module-oss", args);
 }
 #endif
@@ -249,7 +256,7 @@
 static dbus_bool_t hal_device_add(struct userdata *u, const char *udi,
                                   DBusError *error)
 {
-    pa_module* m;
+    pa_module* m =3D NULL;
     struct device *d;
 =

     switch(u->capability) {
@@ -260,7 +267,10 @@
 #endif
 #ifdef HAVE_OSS
         case CAP_OSS:
-            m =3D hal_device_load_oss(u, udi, error);
+#ifdef HAVE_ALSA
+            if (u->use_oss)
+#endif                =

+                m =3D hal_device_load_oss(u, udi, error);
             break;
 #endif
         default:
@@ -492,6 +502,7 @@
     pa_dbus_connection *conn;
     struct userdata *u =3D NULL;
     LibHalContext *hal_ctx =3D NULL;
+    int n =3D 0;
 =

     assert(c);
     assert(m);
@@ -518,13 +529,26 @@
     m->userdata =3D (void*) u;
 =

 #ifdef HAVE_ALSA
-    hal_device_add_all(u, CAP_ALSA);
-#endif
+    n =3D hal_device_add_all(u, CAP_ALSA);
+#endif
+#if defined(HAVE_ALSA) && defined(HAVE_OSS)
+    u->use_oss =3D 0;
+    =

+    if (n <=3D 0) {
+#endif    =

 #ifdef HAVE_OSS
-    hal_device_add_all(u, CAP_OSS);
-#endif
-
-    libhal_ctx_set_user_data(hal_ctx, (void*) u);
+        n +=3D hal_device_add_all(u, CAP_OSS);
+#endif
+#if defined(HAVE_ALSA) && defined(HAVE_OSS)
+
+        /* We found something with OSS, but didn't find anything with
+         * ALSA. Then let's use only OSS from now on. */
+        if (n > 0)
+            u->use_oss =3D 1;
+    }
+#endif    =

+
+    libhal_ctx_set_user_data(hal_ctx, u);
     libhal_ctx_set_device_added(hal_ctx, device_added_cb);
     libhal_ctx_set_device_removed(hal_ctx, device_removed_cb);
     libhal_ctx_set_device_new_capability(hal_ctx, new_capability_cb);




More information about the pulseaudio-commits mailing list