From b3a043fd3179fcb60730466ae43f16ffe14a9b4c Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Tue, 20 Jan 2009 20:34:46 +0100 Subject: always add 'disabled' profile --- src/modules/alsa/module-alsa-card.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/modules/alsa/module-alsa-card.c b/src/modules/alsa/module-alsa-card.c index 1e3c0c1d..ac6083de 100644 --- a/src/modules/alsa/module-alsa-card.c +++ b/src/modules/alsa/module-alsa-card.c @@ -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); -- cgit