blob: 2c5e7d4a6e0e0efd99a539e114dcbb37ed1addd3 [file] [log] [blame]
Brett Cannon22248172008-05-16 00:10:24 +00001from test.test_support import findfile, TestFailed, TestSkipped, import_module
2sunaudiodev = import_module('sunaudiodev', deprecated=True)
Barry Warsaw5bc697d1997-01-07 21:05:29 +00003import os
4
Fred Drakeb8918912001-04-14 03:10:12 +00005try:
6 audiodev = os.environ["AUDIODEV"]
7except KeyError:
8 audiodev = "/dev/audio"
9
10if not os.path.exists(audiodev):
11 raise TestSkipped("no audio device found!")
12
Barry Warsaw5bc697d1997-01-07 21:05:29 +000013def play_sound_file(path):
14 fp = open(path, 'r')
15 data = fp.read()
16 fp.close()
Barry Warsaw3de721d1997-01-13 20:53:46 +000017 try:
Guido van Rossum41360a41998-03-26 19:42:58 +000018 a = sunaudiodev.open('w')
Barry Warsaw3de721d1997-01-13 20:53:46 +000019 except sunaudiodev.error, msg:
Guido van Rossum41360a41998-03-26 19:42:58 +000020 raise TestFailed, msg
Barry Warsaw3de721d1997-01-13 20:53:46 +000021 else:
Guido van Rossum41360a41998-03-26 19:42:58 +000022 a.write(data)
23 a.close()
Barry Warsaw5bc697d1997-01-07 21:05:29 +000024
Brett Cannon7dbd9182008-03-03 04:19:29 +000025
26def test_main():
Barry Warsawb241c421997-01-13 20:34:44 +000027 play_sound_file(findfile('audiotest.au'))
Barry Warsaw5bc697d1997-01-07 21:05:29 +000028
Brett Cannon7dbd9182008-03-03 04:19:29 +000029
30
31if __name__ == '__main__':
32 test_main()