mirror of
https://github.com/larsimmisch/pyalsaaudio.git
synced 2026-06-09 22:12:27 +00:00
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:
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user