[pulseaudio-commits] r1632 - /branches/lennart/src/modules/module-hal-detect.c

svnmailer-noreply at 0pointer.de svnmailer-noreply at 0pointer.de
Sat Aug 11 08:58:16 PDT 2007


Author: lennart
Date: Sat Aug 11 17:58:15 2007
New Revision: 1632

URL: http://0pointer.de/cgi-bin/viewcvs.cgi?rev=3D1632&root=3Dpulseaudio&vi=
ew=3Drev
Log:
fix default device naming and fix api selection code

Modified:
    branches/lennart/src/modules/module-hal-detect.c

Modified: branches/lennart/src/modules/module-hal-detect.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/branches/lennart/src/modules/mo=
dule-hal-detect.c?rev=3D1632&root=3Dpulseaudio&r1=3D1631&r2=3D1632&view=3Dd=
iff
=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
--- branches/lennart/src/modules/module-hal-detect.c (original)
+++ branches/lennart/src/modules/module-hal-detect.c Sat Aug 11 17:58:15 20=
07
@@ -155,7 +155,7 @@
 }
 =

 static pa_module* hal_device_load_alsa(struct userdata *u, const char *udi=
, char **sink_name, char **source_name) {
-    char args[128];
+    char *args;
     alsa_type_t type;
     int device, card;
     const char *module_name;
@@ -189,17 +189,19 @@
         *sink_name =3D pa_sprintf_malloc("alsa_output.%s", strip_udi(udi));
         =

         module_name =3D "module-alsa-sink";
-        pa_snprintf(args, sizeof(args), "device=3Dhw:%u sink_name=3D%s", c=
ard, *sink_name);
+        args =3D pa_sprintf_malloc("device=3Dhw:%u sink_name=3D%s", card, =
*sink_name);
     } else {
-        *source_name =3D pa_sprintf_malloc("alsa_output.%s", strip_udi(udi=
));
+        *source_name =3D pa_sprintf_malloc("alsa_input.%s", strip_udi(udi)=
);
         =

         module_name =3D "module-alsa-source";
-        pa_snprintf(args, sizeof(args), "device=3Dhw:%u source_name=3D%s",=
 card, *source_name);
+        args =3D pa_sprintf_malloc("device=3Dhw:%u source_name=3D%s", card=
, *source_name);
     }
 =

     pa_log_debug("Loading %s with arguments '%s'", module_name, args);
 =

     m =3D pa_module_load(u->core, module_name, args);
+
+    pa_xfree(args);
 =

     if (!m) {
         pa_xfree(*sink_name);
@@ -257,7 +259,7 @@
 }
 =

 static pa_module* hal_device_load_oss(struct userdata *u, const char *udi,=
 char **sink_name, char **source_name) {
-    char args[256];
+    char* args;
     char* device;
     DBusError error;
     pa_module *m;
@@ -277,15 +279,15 @@
     if (!device || dbus_error_is_set(&error))
         goto fail;
 =

-    *sink_name =3D pa_sprintf_malloc("alsa_output.%s", strip_udi(udi));
-    *source_name =3D pa_sprintf_malloc("alsa_output.%s", strip_udi(udi));
-    =

-    pa_snprintf(args, sizeof(args), "device=3D%s sink_name=3D%s source_nam=
e=3D%s", device, sink_name, source_name);
+    *sink_name =3D pa_sprintf_malloc("oss_output.%s", strip_udi(udi));
+    *source_name =3D pa_sprintf_malloc("oss_input.%s", strip_udi(udi));
+    =

+    args =3D pa_sprintf_malloc("device=3D%s sink_name=3D%s source_name=3D%=
s", device, *sink_name, *source_name);
     libhal_free_string(device);
 =

     pa_log_debug("Loading module-oss with arguments '%s'", args);
-
     m =3D pa_module_load(u->core, "module-oss", args);
+    pa_xfree(args);
 =

     if (!m) {
         pa_xfree(*sink_name);
@@ -342,10 +344,12 @@
     char** udis;
 =

     pa_assert(u);
-    pa_assert(!u->capability);
     =

     dbus_error_init(&error);
 =

+    if (u->capability && strcmp(u->capability, capability) !=3D 0)
+        return 0;
+    =

     pa_log_info("Trying capability %s", capability);
 =

     udis =3D libhal_find_device_by_capability(u->context, capability, &n, =
&error);
@@ -356,7 +360,6 @@
     }
 =

     if (n > 0) {
-        u->capability =3D capability;
         =

         for (i =3D 0; i < n; i++) {
             struct device *d;
@@ -741,7 +744,7 @@
     n =3D hal_device_add_all(u, CAPABILITY_ALSA);
 #endif
 #if defined(HAVE_ALSA) && defined(HAVE_OSS)
-    if (!u->capability)
+    if (n <=3D 0)
 #endif        =

 #ifdef HAVE_OSS
         n +=3D hal_device_add_all(u, CAPABILITY_OSS);




More information about the pulseaudio-commits mailing list