mirror of
https://github.com/python/cpython.git
synced 2025-09-27 18:59:43 +00:00
Forward-port r65112 so that test_ossaudiodev uses sunau.
This commit is contained in:
parent
d4d478d1c6
commit
abd9a59763
1 changed files with 9 additions and 8 deletions
|
@ -6,7 +6,7 @@ from test.support import findfile, TestSkipped
|
||||||
import errno
|
import errno
|
||||||
import ossaudiodev
|
import ossaudiodev
|
||||||
import sys
|
import sys
|
||||||
import sunaudio
|
import sunau
|
||||||
import time
|
import time
|
||||||
import audioop
|
import audioop
|
||||||
import unittest
|
import unittest
|
||||||
|
@ -22,15 +22,16 @@ except ImportError:
|
||||||
AFMT_S16_NE = ossaudiodev.AFMT_S16_BE
|
AFMT_S16_NE = ossaudiodev.AFMT_S16_BE
|
||||||
|
|
||||||
|
|
||||||
SND_FORMAT_MULAW_8 = 1
|
|
||||||
|
|
||||||
def read_sound_file(path):
|
def read_sound_file(path):
|
||||||
fp = open(path, 'rb')
|
with open(path, 'rb') as fp:
|
||||||
size, enc, rate, nchannels, extra = sunaudio.gethdr(fp)
|
au = sunau.open(fp)
|
||||||
|
rate = au.getframerate()
|
||||||
|
nchannels = au.getnchannels()
|
||||||
|
encoding = au._encoding
|
||||||
|
fp.seek(0)
|
||||||
data = fp.read()
|
data = fp.read()
|
||||||
fp.close()
|
|
||||||
|
|
||||||
if enc != SND_FORMAT_MULAW_8:
|
if encoding != sunau.AUDIO_FILE_ENCODING_MULAW_8:
|
||||||
raise RuntimeError("Expect .au file with 8-bit mu-law samples")
|
raise RuntimeError("Expect .au file with 8-bit mu-law samples")
|
||||||
|
|
||||||
# Convert the data to 16-bit signed.
|
# Convert the data to 16-bit signed.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue