Fred Drake | 1f2d464 | 2000-06-10 04:22:57 +0000 | [diff] [blame] | 1 | from test_support import verbose, findfile, TestFailed |
| 2 | import linuxaudiodev |
Moshe Zadka | 323a508 | 2000-08-04 12:59:40 +0000 | [diff] [blame^] | 3 | import errno |
Fred Drake | 1f2d464 | 2000-06-10 04:22:57 +0000 | [diff] [blame] | 4 | import os |
| 5 | |
| 6 | def play_sound_file(path): |
| 7 | fp = open(path, 'r') |
| 8 | data = fp.read() |
| 9 | fp.close() |
| 10 | try: |
| 11 | a = linuxaudiodev.open('w') |
| 12 | except linuxaudiodev.error, msg: |
Moshe Zadka | 323a508 | 2000-08-04 12:59:40 +0000 | [diff] [blame^] | 13 | if msg[0] in (errno.EACCES, errno.ENODEV): |
| 14 | raise ImportError, msg |
Fred Drake | 1f2d464 | 2000-06-10 04:22:57 +0000 | [diff] [blame] | 15 | raise TestFailed, msg |
| 16 | else: |
| 17 | a.write(data) |
| 18 | a.close() |
| 19 | |
| 20 | def test(): |
| 21 | play_sound_file(findfile('audiotest.au')) |
| 22 | |
| 23 | test() |