[Python-checkins] python/dist/src/Lib/test test_ossaudiodev.py,1.1,1.2

gward@users.sourceforge.net gward@users.sourceforge.net
Tue, 10 Dec 2002 08:27:40 -0800


Update of /cvsroot/python/python/dist/src/Lib/test
In directory sc8-pr-cvs1:/tmp/cvs-serv32233

Modified Files:
	test_ossaudiodev.py 
Log Message:
Aesthetic tweakery: factor read_sound_file() out of play_sound_file().


Index: test_ossaudiodev.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_ossaudiodev.py,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** test_ossaudiodev.py	10 Dec 2002 16:24:21 -0000	1.1
--- test_ossaudiodev.py	10 Dec 2002 16:27:35 -0000	1.2
***************
*** 13,17 ****
  SND_FORMAT_MULAW_8 = 1
  
! def play_sound_file(path):
      fp = open(path, 'r')
      size, enc, rate, nchannels, extra = sunaudio.gethdr(fp)
--- 13,17 ----
  SND_FORMAT_MULAW_8 = 1
  
! def read_sound_file(path):
      fp = open(path, 'r')
      size, enc, rate, nchannels, extra = sunaudio.gethdr(fp)
***************
*** 23,26 ****
--- 23,32 ----
          return
  
+     # Convert the data to 16-bit signed.
+     data = audioop.ulaw2lin(data, 2)
+     return (data, rate, 16, nchannels)
+ 
+ 
+ def play_sound_file(data, rate, ssize, nchannels):
      try:
          a = ossaudiodev.open('w')
***************
*** 30,36 ****
          raise TestFailed, msg
  
-     # convert the data to 16-bit signed
-     data = audioop.ulaw2lin(data, 2)
- 
      # set the data format
      if sys.byteorder == 'little':
--- 36,39 ----
***************
*** 84,88 ****
  
  def test():
!     play_sound_file(findfile('audiotest.au'))
      test_errors()
  
--- 87,92 ----
  
  def test():
!     (data, rate, ssize, nchannels) = read_sound_file(findfile('audiotest.au'))
!     play_sound_file(data, rate, ssize, nchannels)
      test_errors()