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