2002-07-24 03:04:11 +08:00
|
|
|
from test.test_support import verbose, findfile, TestFailed, TestSkipped
|
1997-01-08 05:05:29 +08:00
|
|
|
import sunaudiodev
|
|
|
|
import os
|
|
|
|
|
2001-04-14 11:10:12 +08:00
|
|
|
try:
|
|
|
|
audiodev = os.environ["AUDIODEV"]
|
|
|
|
except KeyError:
|
|
|
|
audiodev = "/dev/audio"
|
|
|
|
|
|
|
|
if not os.path.exists(audiodev):
|
|
|
|
raise TestSkipped("no audio device found!")
|
|
|
|
|
1997-01-08 05:05:29 +08:00
|
|
|
def play_sound_file(path):
|
|
|
|
fp = open(path, 'r')
|
|
|
|
data = fp.read()
|
|
|
|
fp.close()
|
1997-01-14 04:53:46 +08:00
|
|
|
try:
|
1998-03-27 03:42:58 +08:00
|
|
|
a = sunaudiodev.open('w')
|
1997-01-14 04:53:46 +08:00
|
|
|
except sunaudiodev.error, msg:
|
1998-03-27 03:42:58 +08:00
|
|
|
raise TestFailed, msg
|
1997-01-14 04:53:46 +08:00
|
|
|
else:
|
1998-03-27 03:42:58 +08:00
|
|
|
a.write(data)
|
|
|
|
a.close()
|
1997-01-08 05:05:29 +08:00
|
|
|
|
|
|
|
def test():
|
1997-01-14 04:34:44 +08:00
|
|
|
play_sound_file(findfile('audiotest.au'))
|
1997-01-08 05:05:29 +08:00
|
|
|
|
|
|
|
test()
|