mirror of
https://github.com/python/cpython.git
synced 2025-11-25 04:34:37 +00:00
Deprecate the sunaudio module for removal in Python 3.0. The sunau module can provide similar functionality.
This commit is contained in:
parent
56af5fcab7
commit
1e8fba729e
5 changed files with 21 additions and 10 deletions
|
|
@ -6,7 +6,7 @@ from test.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()
|
||||
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 enc != SND_FORMAT_MULAW_8:
|
||||
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.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue