card-restore: don't restore unavailable profiles
authorTanu Kaskinen <tanuk@iki.fi>
Wed, 8 Nov 2017 12:20:23 +0000 (14:20 +0200)
committerTanu Kaskinen <tanuk@iki.fi>
Tue, 21 Nov 2017 13:15:34 +0000 (15:15 +0200)
src/modules/module-card-restore.c

index 2d3a91c..b7189ad 100644 (file)
@@ -561,8 +561,12 @@ static pa_hook_result_t card_choose_initial_profile_callback(pa_core *core, pa_c
 
         profile = pa_hashmap_get(card->profiles, e->profile);
         if (profile) {
-            pa_log_info("Restoring profile '%s' for card %s.", profile->name, card->name);
-            pa_card_set_profile(card, profile, true);
+            if (profile->available != PA_AVAILABLE_NO) {
+                pa_log_info("Restoring profile '%s' for card %s.", profile->name, card->name);
+                pa_card_set_profile(card, profile, true);
+            } else
+                pa_log_debug("Not restoring profile %s for card %s, because the profile is currently unavailable.",
+                             profile->name, card->name);
         } else {
             pa_log_debug("Tried to restore profile %s for card %s, but the card doesn't have such profile.",
                          e->profile, card->name);