diff options
author | Greg Ward <gward@python.net> | 2003-06-03 00:32:44 (GMT) |
---|---|---|
committer | Greg Ward <gward@python.net> | 2003-06-03 00:32:44 (GMT) |
commit | 8a709b30493e7ca36e203d213d19f6fde8740470 (patch) | |
tree | e0caaf247bf2f778a889ddc914c83674c647fa7a /Lib/test | |
parent | 3800ef7ae2391e3bf6573b41fc6ac513cd3dde82 (diff) | |
download | cpython-8a709b30493e7ca36e203d213d19f6fde8740470.zip cpython-8a709b30493e7ca36e203d213d19f6fde8740470.tar.gz cpython-8a709b30493e7ca36e203d213d19f6fde8740470.tar.bz2 |
Factor endian-ness check out of play_sound_file(), and fix
test_setparameters() to use it -- don't assume AFMT_S16_NE is always
defined!
Diffstat (limited to 'Lib/test')
-rw-r--r-- | Lib/test/test_ossaudiodev.py | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/Lib/test/test_ossaudiodev.py b/Lib/test/test_ossaudiodev.py index 729f6ea..21aa0ff 100644 --- a/Lib/test/test_ossaudiodev.py +++ b/Lib/test/test_ossaudiodev.py @@ -13,6 +13,17 @@ import sunaudio import time import audioop +# Arggh, AFMT_S16_NE not defined on all platforms -- seems to be a +# fairly recent addition to OSS. +try: + from ossaudiodev import AFMT_S16_NE +except ImportError: + if sys.byteorder == "little": + AFMT_S16_NE = ossaudiodev.AFMT_S16_LE + else: + AFMT_S16_NE = ossaudiodev.AFMT_S16_BE + + SND_FORMAT_MULAW_8 = 1 def read_sound_file(path): @@ -38,12 +49,6 @@ def play_sound_file(data, rate, ssize, nchannels): raise TestSkipped, msg raise TestFailed, msg - # set the data format - if sys.byteorder == 'little': - fmt = ossaudiodev.AFMT_S16_LE - else: - fmt = ossaudiodev.AFMT_S16_BE - # at least check that these methods can be invoked dsp.bufsize() dsp.obufcount() @@ -52,7 +57,7 @@ def play_sound_file(data, rate, ssize, nchannels): dsp.fileno() # set parameters based on .au file headers - dsp.setparameters(fmt, nchannels, rate) + dsp.setparameters(AFMT_S16_NE, nchannels, rate) t1 = time.time() print "playing test sound file..." dsp.write(data) |