mirror of https://github.com/python/cpython
Order and number of arguments to setparameters() has changed.
Rename 'a' (the audio device) to 'dsp' everywhere.
This commit is contained in:
parent
d1c5510b99
commit
080c110172
|
@ -32,7 +32,7 @@ def read_sound_file(path):
|
||||||
|
|
||||||
def play_sound_file(data, rate, ssize, nchannels):
|
def play_sound_file(data, rate, ssize, nchannels):
|
||||||
try:
|
try:
|
||||||
a = ossaudiodev.open('w')
|
dsp = ossaudiodev.open('w')
|
||||||
except IOError, msg:
|
except IOError, msg:
|
||||||
if msg[0] in (errno.EACCES, errno.ENODEV, errno.EBUSY):
|
if msg[0] in (errno.EACCES, errno.ENODEV, errno.EBUSY):
|
||||||
raise TestSkipped, msg
|
raise TestSkipped, msg
|
||||||
|
@ -45,47 +45,46 @@ def play_sound_file(data, rate, ssize, nchannels):
|
||||||
fmt = ossaudiodev.AFMT_S16_BE
|
fmt = ossaudiodev.AFMT_S16_BE
|
||||||
|
|
||||||
# at least check that these methods can be invoked
|
# at least check that these methods can be invoked
|
||||||
a.bufsize()
|
dsp.bufsize()
|
||||||
a.obufcount()
|
dsp.obufcount()
|
||||||
a.obuffree()
|
dsp.obuffree()
|
||||||
a.getptr()
|
dsp.getptr()
|
||||||
a.fileno()
|
dsp.fileno()
|
||||||
|
|
||||||
# set parameters based on .au file headers
|
# set parameters based on .au file headers
|
||||||
a.setparameters(rate, 16, nchannels, fmt)
|
dsp.setparameters(fmt, nchannels, rate)
|
||||||
a.write(data)
|
dsp.write(data)
|
||||||
a.flush()
|
dsp.flush()
|
||||||
a.close()
|
dsp.close()
|
||||||
|
|
||||||
def test_errors():
|
def test_errors():
|
||||||
a = ossaudiodev.open("w")
|
dsp = ossaudiodev.open("w")
|
||||||
size = 8
|
|
||||||
fmt = ossaudiodev.AFMT_U8
|
fmt = ossaudiodev.AFMT_U8
|
||||||
rate = 8000
|
rate = 8000
|
||||||
nchannels = 1
|
nchannels = 1
|
||||||
try:
|
try:
|
||||||
a.setparameters(-1, size, nchannels, fmt)
|
dsp.setparameters(fmt, nchannels, -1)
|
||||||
except ValueError, msg:
|
except ossaudiodev.error, msg:
|
||||||
print msg
|
print msg
|
||||||
try:
|
try:
|
||||||
a.setparameters(rate, -2, nchannels, fmt)
|
dsp.setparameters(fmt, nchannels, rate)
|
||||||
except ValueError, msg:
|
except ossaudiodev.error, msg:
|
||||||
print msg
|
print msg
|
||||||
try:
|
try:
|
||||||
a.setparameters(rate, size, 3, fmt)
|
dsp.setparameters(fmt, 3, rate)
|
||||||
except ValueError, msg:
|
except ossaudiodev.error, msg:
|
||||||
print msg
|
print msg
|
||||||
try:
|
try:
|
||||||
a.setparameters(rate, size, nchannels, 177)
|
dsp.setparameters(177, nchannels, rate)
|
||||||
except ValueError, msg:
|
except ossaudiodev.error, msg:
|
||||||
print msg
|
print msg
|
||||||
try:
|
try:
|
||||||
a.setparameters(rate, size, nchannels, ossaudiodev.AFMT_U16_LE)
|
dsp.setparameters(ossaudiodev.AFMT_U16_LE, nchannels, rate)
|
||||||
except ValueError, msg:
|
except ossaudiodev.error, msg:
|
||||||
print msg
|
print msg
|
||||||
try:
|
try:
|
||||||
a.setparameters(rate, 16, nchannels, fmt)
|
dsp.setparameters(rate, nchannels, fmt)
|
||||||
except ValueError, msg:
|
except ossaudiodev.error, msg:
|
||||||
print msg
|
print msg
|
||||||
|
|
||||||
def test():
|
def test():
|
||||||
|
|
Loading…
Reference in New Issue