Fred Drake | b891891 | 2001-04-14 03:10:12 +0000 | [diff] [blame] | 1 | from test_support import verbose, findfile, TestFailed, TestSkipped |
Barry Warsaw | 5bc697d | 1997-01-07 21:05:29 +0000 | [diff] [blame] | 2 | import sunaudiodev |
| 3 | import os |
| 4 | |
Fred Drake | b891891 | 2001-04-14 03:10:12 +0000 | [diff] [blame] | 5 | try: |
| 6 | audiodev = os.environ["AUDIODEV"] |
| 7 | except KeyError: |
| 8 | audiodev = "/dev/audio" |
| 9 | |
| 10 | if not os.path.exists(audiodev): |
| 11 | raise TestSkipped("no audio device found!") |
| 12 | |
Barry Warsaw | 5bc697d | 1997-01-07 21:05:29 +0000 | [diff] [blame] | 13 | def play_sound_file(path): |
| 14 | fp = open(path, 'r') |
| 15 | data = fp.read() |
| 16 | fp.close() |
Barry Warsaw | 3de721d | 1997-01-13 20:53:46 +0000 | [diff] [blame] | 17 | try: |
Guido van Rossum | 41360a4 | 1998-03-26 19:42:58 +0000 | [diff] [blame] | 18 | a = sunaudiodev.open('w') |
Barry Warsaw | 3de721d | 1997-01-13 20:53:46 +0000 | [diff] [blame] | 19 | except sunaudiodev.error, msg: |
Guido van Rossum | 41360a4 | 1998-03-26 19:42:58 +0000 | [diff] [blame] | 20 | raise TestFailed, msg |
Barry Warsaw | 3de721d | 1997-01-13 20:53:46 +0000 | [diff] [blame] | 21 | else: |
Guido van Rossum | 41360a4 | 1998-03-26 19:42:58 +0000 | [diff] [blame] | 22 | a.write(data) |
| 23 | a.close() |
Barry Warsaw | 5bc697d | 1997-01-07 21:05:29 +0000 | [diff] [blame] | 24 | |
| 25 | def test(): |
Barry Warsaw | b241c42 | 1997-01-13 20:34:44 +0000 | [diff] [blame] | 26 | play_sound_file(findfile('audiotest.au')) |
Barry Warsaw | 5bc697d | 1997-01-07 21:05:29 +0000 | [diff] [blame] | 27 | |
| 28 | test() |