1997-01-07 21:05:29 +00:00
|
|
|
from test_support import verbose, TestFailed
|
|
|
|
import sunaudiodev
|
|
|
|
import os
|
|
|
|
|
1997-01-13 20:34:44 +00:00
|
|
|
def findfile(file):
|
1998-03-26 19:42:58 +00:00
|
|
|
if os.path.isabs(file): return file
|
|
|
|
import sys
|
|
|
|
path = sys.path
|
|
|
|
try:
|
|
|
|
path = [os.path.dirname(__file__)] + path
|
|
|
|
except NameError:
|
|
|
|
pass
|
|
|
|
for dn in path:
|
|
|
|
fn = os.path.join(dn, file)
|
|
|
|
if os.path.exists(fn): return fn
|
|
|
|
return file
|
1997-01-07 21:05:29 +00:00
|
|
|
|
|
|
|
def play_sound_file(path):
|
|
|
|
fp = open(path, 'r')
|
|
|
|
data = fp.read()
|
|
|
|
fp.close()
|
1997-01-13 20:53:46 +00:00
|
|
|
try:
|
1998-03-26 19:42:58 +00:00
|
|
|
a = sunaudiodev.open('w')
|
1997-01-13 20:53:46 +00:00
|
|
|
except sunaudiodev.error, msg:
|
1998-03-26 19:42:58 +00:00
|
|
|
raise TestFailed, msg
|
1997-01-13 20:53:46 +00:00
|
|
|
else:
|
1998-03-26 19:42:58 +00:00
|
|
|
a.write(data)
|
|
|
|
a.close()
|
1997-01-07 21:05:29 +00:00
|
|
|
|
|
|
|
def test():
|
1997-01-13 20:34:44 +00:00
|
|
|
play_sound_file(findfile('audiotest.au'))
|
1997-01-07 21:05:29 +00:00
|
|
|
|
|
|
|
test()
|