#include <errno.h>
#include <stdlib.h>
#include <sys/types.h>
-#include <sys/stat.h>
#include <pulse/xmalloc.h>
-#include <pulse/timeval.h>
-#include <pulsecore/core-error.h>
#include <pulsecore/module.h>
#include <pulsecore/log.h>
#include <pulsecore/hashmap.h>
#include <pulsecore/idxset.h>
#include <pulsecore/core-util.h>
#include <pulsecore/namereg.h>
-#include <pulsecore/core-scache.h>
#include <pulsecore/modargs.h>
#include <pulsecore/dbus-shared.h>
PA_MODULE_DESCRIPTION("Detect available audio hardware and load matching drivers");
PA_MODULE_VERSION(PACKAGE_VERSION);
PA_MODULE_LOAD_ONCE(TRUE);
-#if defined(HAVE_ALSA) && defined(HAVE_OSS)
+#if defined(HAVE_ALSA) && defined(HAVE_OSS_OUTPUT)
PA_MODULE_USAGE("api=<alsa or oss> "
- "tsched=<enable system timer based scheduling mode?>");
+ "tsched=<enable system timer based scheduling mode?> "
+ "subdevices=<init all subdevices>");
#elif defined(HAVE_ALSA)
PA_MODULE_USAGE("api=<alsa> "
"tsched=<enable system timer based scheduling mode?>");
-#elif defined(HAVE_OSS)
-PA_MODULE_USAGE("api=<oss>");
+#elif defined(HAVE_OSS_OUTPUT)
+PA_MODULE_USAGE("api=<oss> "
+ "subdevices=<init all subdevices>");
#endif
PA_MODULE_DEPRECATED("Please use module-udev-detect instead of module-hal-detect!");
#ifdef HAVE_ALSA
pa_bool_t use_tsched;
#endif
+#ifdef HAVE_OSS_OUTPUT
+ pa_bool_t init_subdevs;
+#endif
+ pa_bool_t filter_added:1;
};
#define CAPABILITY_ALSA "alsa"
"api",
#ifdef HAVE_ALSA
"tsched",
+#endif
+#ifdef HAVE_OSS_OUTPUT
+ "subdevices",
#endif
NULL
};
/* For each ALSA card that appears the control device will be the
* last one to be created, this is considered part of the ALSA
- * usperspace API. We rely on this and load our modules only when
+ * userspace API. We rely on this and load our modules only when
* the control device is available assuming that *all* device
* nodes have been properly created and assigned the right ACLs at
* that time. Also see:
#endif
-#ifdef HAVE_OSS
+#ifdef HAVE_OSS_OUTPUT
-static pa_bool_t hal_oss_device_is_pcm(LibHalContext *context, const char *udi) {
+static pa_bool_t hal_oss_device_is_pcm(LibHalContext *context, const char *udi, pa_bool_t init_subdevices) {
char *class = NULL, *dev = NULL, *e;
int device;
pa_bool_t r = FALSE;
/* We only care for the main device */
device = libhal_device_get_property_int(context, udi, "oss.device", &error);
- if (dbus_error_is_set(&error) || device != 0)
+ if (dbus_error_is_set(&error) || (device != 0 && init_subdevices == FALSE))
goto finish;
r = TRUE;
pa_assert(d);
/* We only care for OSS PCM devices */
- if (!hal_oss_device_is_pcm(u->context, udi))
+ if (!hal_oss_device_is_pcm(u->context, udi, u->init_subdevs))
goto fail;
/* We store only one entry per card, hence we look for the originating device */
if (pa_streq(u->capability, CAPABILITY_ALSA))
r = hal_device_load_alsa(u, udi, d);
#endif
-#ifdef HAVE_OSS
+#ifdef HAVE_OSS_OUTPUT
if (pa_streq(u->capability, CAPABILITY_OSS))
r = hal_device_load_oss(u, udi, d);
#endif
int i;
for (i = 0; i < n; i++) {
- struct device *d;
-
- if ((d = hal_device_add(u, udis[i]))) {
+ if (hal_device_add(u, udis[i])) {
count++;
pa_log_debug("Loaded device %s", udis[i]);
} else
}
- return DBUS_HANDLER_RESULT_HANDLED;
-
} else if (dbus_message_is_signal(message, "org.pulseaudio.Server", "DirtyGiveUpMessage")) {
/* We use this message to avoid a dirty race condition when we
get an ACLAdded message before the previously owning PA
/* Yes, we don't check the UDI for validity, but hopefully HAL will */
device_added_cb(u->context, udi);
- return DBUS_HANDLER_RESULT_HANDLED;
}
finish:
goto fail;
}
- m->userdata = u = pa_xnew(struct userdata, 1);
+ m->userdata = u = pa_xnew0(struct userdata, 1);
u->core = m->core;
- u->context = NULL;
- u->connection = NULL;
u->devices = pa_hashmap_new(pa_idxset_string_hash_func, pa_idxset_string_compare_func);
- u->capability = NULL;
#ifdef HAVE_ALSA
u->use_tsched = TRUE;
api = pa_modargs_get_value(ma, "api", "oss");
#endif
-#ifdef HAVE_OSS
+#ifdef HAVE_OSS_OUTPUT
if (pa_streq(api, "oss"))
u->capability = CAPABILITY_OSS;
#endif
goto fail;
}
+#ifdef HAVE_OSS_OUTPUT
+ if (pa_modargs_get_value_boolean(ma, "subdevices", &u->init_subdevs) < 0) {
+ pa_log("Failed to parse subdevices= argument.");
+ goto fail;
+ }
+#endif
+
if (!(u->connection = pa_dbus_bus_get(m->core, DBUS_BUS_SYSTEM, &error)) || dbus_error_is_set(&error)) {
pa_log_error("Unable to contact DBUS system bus: %s: %s", error.name, error.message);
goto fail;
pa_log_error("Failed to add filter function");
goto fail;
}
+ u->filter_added = TRUE;
if (pa_dbus_add_matches(
pa_dbus_connection_get(u->connection), &error,
"type='signal',sender='org.freedesktop.Hal',interface='org.freedesktop.Hal.Device.AccessControl',member='ACLRemoved'",
"type='signal',interface='org.pulseaudio.Server',member='DirtyGiveUpMessage'", NULL);
- dbus_connection_remove_filter(pa_dbus_connection_get(u->connection), filter_cb, u);
+ if (u->filter_added)
+ dbus_connection_remove_filter(pa_dbus_connection_get(u->connection), filter_cb, u);
pa_dbus_connection_unref(u->connection);
}