Skip to content

Commit

Permalink
fixed unknown output
Browse files Browse the repository at this point in the history
  • Loading branch information
sezanzeb committed Sep 25, 2020
1 parent 28d3446 commit d68aef1
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
10 changes: 9 additions & 1 deletion alsacontrol/cards.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,13 @@ def get_card(pcm):
card = pcm.split(':CARD=')[1].split(',')[0]
return card
# unsupported card
return None
logger.warning(
'Encountered unsupported non-hw pcm "%s". Did you mean to set '
'the config to "hw:CARD=%s"?',
pcm,
pcm
)
return pcm


def get_cards():
Expand Down Expand Up @@ -120,6 +126,7 @@ def get_current_card(source):
A tuple of (d, card) with d being the index in the list of options
from get_cards.
"""
print('get_current_card')
pcm_name = get_config().get(source)
if pcm_name == 'null':
logger.warning('No input selected')
Expand All @@ -133,6 +140,7 @@ def get_current_card(source):
card = get_card(pcm_name)
if card not in cards:
logger.warning('Found unknown %s "%s" in config', source, pcm_name)
print('a', card)
return None, card

index = cards.index(card)
Expand Down
8 changes: 6 additions & 2 deletions bin/alsacontrol-gtk
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ class ALSAControlWindow:
"""Select the configured values for both dropdowns."""
with self.dropdown_handlers_disabled():
index, card = get_current_card('pcm_output')
if card is not None:
if index is not None:
card_selection = self.card_selection
if card_selection.get_active() != index:
card_selection.set_active(index)
Expand All @@ -441,7 +441,7 @@ class ALSAControlWindow:
self.card_selection.append(card, card)
# since all cards have been removed, restore the selection
index, card = get_current_card('pcm_output')
if card is not None:
if index is not None:
self.card_selection.set_active(index)

def on_output_card_selected(self, card_dropdown):
Expand Down Expand Up @@ -589,8 +589,11 @@ class ALSAControlWindow:
If None, will show the current output, but it won't modify
asoundrc unlike select_current_input in that case.
"""
print('display_input')
if card is None:
print('display_input card is none')
card = get_current_card('pcm_input')[1]
print('display_input', card)

label = self.builder.get_object('input_card_name')

Expand All @@ -605,6 +608,7 @@ class ALSAControlWindow:
input_row.set_active(1)

cards = get_cards()
print('display_input', card, cards)
if card in cards:
label.set_label(card)
else:
Expand Down

0 comments on commit d68aef1

Please sign in to comment.