Add functions for listing cards and their names

The cards() method does not guarantee that the index in its return
value is the same as the actual card index. Provide a way to get this
information in the form of a card_indexes() function, returning a
list of available card indexes.

Add another method, card_name(), which, given a card index, returns
the short and long names of that card.
This commit is contained in:
Chris Diamand
2017-02-08 21:30:11 +00:00
parent bf24ec65ca
commit 2314aaeb7e
2 changed files with 80 additions and 0 deletions
+8
View File
@@ -23,6 +23,12 @@ import sys
import getopt
import alsaaudio
def list_cards():
print("Available sound cards:")
for i in alsaaudio.card_indexes():
(name, longname) = alsaaudio.card_name(i)
print(" %d: %s (%s)" % (i, name, longname))
def list_mixers(kwargs):
print("Available mixer controls:")
for m in alsaaudio.mixers(**kwargs):
@@ -113,6 +119,8 @@ if __name__ == '__main__':
else:
usage()
list_cards()
if not len(args):
list_mixers(kwargs)
elif len(args) == 1: