Make tests more robust, use devices or card indices.

This commit is contained in:
Lars Immisch
2017-02-22 23:55:17 +01:00
parent 85ff47ad43
commit dc51fa75b5
5 changed files with 26 additions and 35 deletions
+6 -6
View File
@@ -21,17 +21,17 @@ import getopt
import alsaaudio
def usage():
print('usage: playbacktest.py [-c <card>] <file>', file=sys.stderr)
print('usage: playbacktest.py [-d <device>] <file>', file=sys.stderr)
sys.exit(2)
if __name__ == '__main__':
card = 'default'
device = 'default'
opts, args = getopt.getopt(sys.argv[1:], 'c:')
opts, args = getopt.getopt(sys.argv[1:], 'd:')
for o, a in opts:
if o == '-c':
card = a
if o == '-d':
device = a
if not args:
usage()
@@ -39,7 +39,7 @@ if __name__ == '__main__':
f = open(args[0], 'rb')
# Open the device in playback mode.
out = alsaaudio.PCM(alsaaudio.PCM_PLAYBACK, card=card)
out = alsaaudio.PCM(alsaaudio.PCM_PLAYBACK, device=device)
# Set attributes: Mono, 44100 Hz, 16 bit little endian frames
out.setchannels(1)