blob: f203d9a304bf62554e2d39498004d6249dff56db [file] [log] [blame]
Barry Warsaw04f357c2002-07-23 19:04:11 +00001from test.test_support import verbose, findfile, TestFailed, TestSkipped
Barry Warsaw5bc697d1997-01-07 21:05:29 +00002import sunaudiodev
3import 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
25def test():
Barry Warsawb241c421997-01-13 20:34:44 +000026 play_sound_file(findfile('audiotest.au'))
Barry Warsaw5bc697d1997-01-07 21:05:29 +000027
28test()