allow global tsched setting for all modules loaded by module-hal

This commit is contained in:
Lennart Poettering 2008-07-31 21:24:23 +02:00
parent 4ccbc4dbe2
commit 4f3193dbef
2 changed files with 20 additions and 5 deletions

View file

@ -56,9 +56,11 @@ 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)
PA_MODULE_USAGE("api=<alsa or oss>");
PA_MODULE_USAGE("api=<alsa or oss> "
"tsched=<enable system timer based scheduling mode?>");
#elif defined(HAVE_ALSA)
PA_MODULE_USAGE("api=<alsa>");
PA_MODULE_USAGE("api=<alsa> "
"tsched=<enable system timer based scheduling mode?>");
#elif defined(HAVE_OSS)
PA_MODULE_USAGE("api=<oss>");
#endif
@ -76,6 +78,9 @@ struct userdata {
pa_dbus_connection *connection;
pa_hashmap *devices;
const char *capability;
#ifdef HAVE_ALSA
pa_bool_t use_tsched;
#endif
};
struct timerdata {
@ -88,6 +93,9 @@ struct timerdata {
static const char* const valid_modargs[] = {
"api",
#ifdef HAVE_ALSA
"tsched",
#endif
NULL
};
@ -189,12 +197,12 @@ static pa_module* hal_device_load_alsa(struct userdata *u, const char *udi, char
*sink_name = pa_sprintf_malloc("alsa_output.%s", strip_udi(udi));
module_name = "module-alsa-sink";
args = pa_sprintf_malloc("device_id=%u sink_name=%s", card, *sink_name);
args = pa_sprintf_malloc("device_id=%u sink_name=%s tsched=%i", card, *sink_name, (int) u->use_tsched);
} else {
*source_name = pa_sprintf_malloc("alsa_input.%s", strip_udi(udi));
module_name = "module-alsa-source";
args = pa_sprintf_malloc("device_id=%u source_name=%s", card, *source_name);
args = pa_sprintf_malloc("device_id=%u source_name=%s tsched=%i", card, *source_name, (int) u->use_tsched);
}
pa_log_debug("Loading %s with arguments '%s'", module_name, args);
@ -724,6 +732,7 @@ int pa__init(pa_module*m) {
int n = 0;
pa_modargs *ma;
const char *api;
pa_bool_t use_tsched = TRUE;
pa_assert(m);
@ -734,6 +743,11 @@ int pa__init(pa_module*m) {
goto fail;
}
if (pa_modargs_get_value_boolean(ma, "tsched", &use_tsched) < 0) {
pa_log("Failed to parse tsched argument.");
goto fail;
}
if ((api = pa_modargs_get_value(ma, "api", NULL))) {
int good = 0;
@ -775,6 +789,7 @@ int pa__init(pa_module*m) {
u->connection = conn;
u->devices = pa_hashmap_new(pa_idxset_string_hash_func, pa_idxset_string_compare_func);
u->capability = api;
u->use_tsched = use_tsched;
m->userdata = u;
#ifdef HAVE_ALSA