from test
import test_support
test_support
.requires('audio')
from test
.test_support
import verbose
, findfile
, TestFailed
, TestSkipped
def play_sound_file(path
):
size
, enc
, rate
, nchannels
, extra
= sunaudio
.gethdr(fp
)
if enc
!= SND_FORMAT_MULAW_8
:
print "Expect .au file with 8-bit mu-law samples"
a
= linuxaudiodev
.open('w')
except linuxaudiodev
.error
, msg
:
if msg
[0] in (errno
.EACCES
, errno
.ENODEV
, errno
.EBUSY
):
# convert the data to 16-bit signed
data
= audioop
.ulaw2lin(data
, 2)
if sys
.byteorder
== 'little':
fmt
= linuxaudiodev
.AFMT_S16_LE
fmt
= linuxaudiodev
.AFMT_S16_BE
# at least check that these methods can be invoked
# set parameters based on .au file headers
a
.setparameters(rate
, 16, nchannels
, fmt
)
a
= linuxaudiodev
.open("w")
fmt
= linuxaudiodev
.AFMT_U8
a
.setparameters(-1, size
, nchannels
, fmt
)
a
.setparameters(rate
, -2, nchannels
, fmt
)
a
.setparameters(rate
, size
, 3, fmt
)
a
.setparameters(rate
, size
, nchannels
, 177)
a
.setparameters(rate
, size
, nchannels
, linuxaudiodev
.AFMT_U16_LE
)
a
.setparameters(rate
, 16, nchannels
, fmt
)
play_sound_file(findfile('audiotest.au'))