]> granicus.if.org Git - python/commitdiff
Forward-port r65112 so that test_ossaudiodev uses sunau.
authorBrett Cannon <bcannon@gmail.com>
Fri, 25 Jul 2008 17:56:47 +0000 (17:56 +0000)
committerBrett Cannon <bcannon@gmail.com>
Fri, 25 Jul 2008 17:56:47 +0000 (17:56 +0000)
Lib/test/test_ossaudiodev.py

index 6f8de97ccc593637183f11c4d50005795d5431e9..e07ad1b095df6dacf958b78fd4eec57a43f1e9c0 100644 (file)
@@ -6,7 +6,7 @@ from test.support import findfile, TestSkipped
 import errno
 import ossaudiodev
 import sys
-import sunaudio
+import sunau
 import time
 import audioop
 import unittest
@@ -22,15 +22,16 @@ except ImportError:
         AFMT_S16_NE = ossaudiodev.AFMT_S16_BE
 
 
-SND_FORMAT_MULAW_8 = 1
-
 def read_sound_file(path):
-    fp = open(path, 'rb')
-    size, enc, rate, nchannels, extra = sunaudio.gethdr(fp)
-    data = fp.read()
-    fp.close()
-
-    if enc != SND_FORMAT_MULAW_8:
+    with open(path, 'rb') as fp:
+        au = sunau.open(fp)
+        rate = au.getframerate()
+        nchannels = au.getnchannels()
+        encoding = au._encoding
+        fp.seek(0)
+        data = fp.read()
+
+    if encoding != sunau.AUDIO_FILE_ENCODING_MULAW_8:
         raise RuntimeError("Expect .au file with 8-bit mu-law samples")
 
     # Convert the data to 16-bit signed.