]> code.delx.au - pulseaudio/commitdiff
always add 'disabled' profile
authorLennart Poettering <lennart@poettering.net>
Tue, 20 Jan 2009 19:34:46 +0000 (20:34 +0100)
committerLennart Poettering <lennart@poettering.net>
Tue, 20 Jan 2009 19:34:46 +0000 (20:34 +0100)
src/modules/alsa/module-alsa-card.c

index 1e3c0c1d845c4394219dd31d2de1b3ddab76f2f9..ac6083defa77c42bf0445b2ea07e633f30f30dc2 100644 (file)
@@ -97,7 +97,6 @@ static void enumerate_cb(
         t = pa_sprintf_malloc("Output %s", sink->description);
     } else {
         pa_assert(source);
-        n = pa_xstrdup(source->name);
         n = pa_sprintf_malloc("input-%s", source->name);
         t = pa_sprintf_malloc("Input %s", source->description);
     }
@@ -125,6 +124,18 @@ static void enumerate_cb(
     pa_hashmap_put(profiles, p->name, p);
 }
 
+static void add_disabled_profile(pa_hashmap *profiles) {
+    pa_card_profile *p;
+    struct profile_data *d;
+
+    p = pa_card_profile_new("off", "Off", sizeof(struct profile_data));
+
+    d = PA_CARD_PROFILE_DATA(p);
+    d->sink = d->source = NULL;
+
+    pa_hashmap_put(profiles, p->name, p);
+}
+
 int pa__init(pa_module*m) {
     pa_card_new_data data;
     pa_modargs *ma;
@@ -163,6 +174,14 @@ int pa__init(pa_module*m) {
         goto fail;
     }
 
+    if (pa_hashmap_isempty(data.profiles)) {
+        pa_log("Failed to find a working profile.");
+        pa_card_new_data_done(&data);
+        goto fail;
+    }
+
+    add_disabled_profile(data.profiles);
+
     u->card = pa_card_new(m->core, &data);
     pa_card_new_data_done(&data);