Index: Lib/test/test_linuxaudiodev.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_linuxaudiodev.py,v retrieving revision 1.8 diff -u -r1.8 test_linuxaudiodev.py --- Lib/test/test_linuxaudiodev.py 23 Jul 2002 19:03:56 -0000 1.8 +++ Lib/test/test_linuxaudiodev.py 27 Nov 2002 22:12:53 -0000 @@ -12,7 +12,7 @@ SND_FORMAT_MULAW_8 = 1 -def play_sound_file(path): +def read_sound_file(path): fp = open(path, 'r') size, enc, rate, nchannels, extra = sunaudio.gethdr(fp) data = fp.read() @@ -22,16 +22,22 @@ print "Expect .au file with 8-bit mu-law samples" return + # Convert the data to 16-bit signed. + data = audioop.ulaw2lin(data, 2) + return (data, rate, 16, nchannels) + + +def play_sound_file(data, rate, ssize, nchannels, device=None): try: - a = linuxaudiodev.open('w') + if device is None: + a = linuxaudiodev.open('w') + else: + a = linuxaudiodev.open(device, 'w') except linuxaudiodev.error, msg: if msg[0] in (errno.EACCES, errno.ENODEV, errno.EBUSY): raise TestSkipped, msg raise TestFailed, msg - # convert the data to 16-bit signed - data = audioop.ulaw2lin(data, 2) - # set the data format if sys.byteorder == 'little': fmt = linuxaudiodev.AFMT_S16_LE @@ -83,7 +89,9 @@ print msg def test(): - play_sound_file(findfile('audiotest.au')) + (data, rate, ssize, nchannels) = read_sound_file(findfile('audiotest.au')) + play_sound_file(data, rate, ssize, nchannels) + play_sound_file(data, rate, ssize, nchannels, device="/dev/dsp") test_errors() test()