Commits

William Manire committed 948cdd2

Added the AUDIO_FORMATS to a set and thoroughly tested the audio format macros

Comments (0)

Files changed (2)

 AUDIO_F32MSB = 0x9120
 AUDIO_F32 = AUDIO_F32LSB
 
+
+# All of the audio formats should be in this set which is provided as a
+# convenience to the end user for purposes of iteration and validation.
+# (is the provided audio format in the supported set?)
+AUDIO_FORMATS = set([AUDIO_U8, AUDIO_S8, AUDIO_U16LSB, AUDIO_S16LSB,
+                     AUDIO_U16MSB, AUDIO_S16MSB, AUDIO_U16, AUDIO_S16,
+                     AUDIO_S32LSB, AUDIO_S32MSB, AUDIO_S32, AUDIO_F32LSB,
+                     AUDIO_F32MSB, AUDIO_F32])
+
 if SDL_BYTEORDER == SDL_LIL_ENDIAN:
     AUDIO_U16SYS = AUDIO_U16LSB
     AUDIO_S16SYS = AUDIO_S16LSB

sdl2/test/audio_test.py

         SDL_Quit()
 
     def test_SDL_AUDIO_BITSIZE(self):
-        self.assertEqual(audio.SDL_AUDIO_BITSIZE(audio.AUDIO_U16LSB), 0x0010)
+        self.assertEqual(audio.SDL_AUDIO_BITSIZE(audio.AUDIO_U8), 8)
+        self.assertEqual(audio.SDL_AUDIO_BITSIZE(audio.AUDIO_S8), 8)
+        self.assertEqual(audio.SDL_AUDIO_BITSIZE(audio.AUDIO_U16LSB), 16)
+        self.assertEqual(audio.SDL_AUDIO_BITSIZE(audio.AUDIO_S16LSB), 16)
+        self.assertEqual(audio.SDL_AUDIO_BITSIZE(audio.AUDIO_U16MSB), 16)
+        self.assertEqual(audio.SDL_AUDIO_BITSIZE(audio.AUDIO_S16MSB), 16)
+        self.assertEqual(audio.SDL_AUDIO_BITSIZE(audio.AUDIO_U16), 16)
+        self.assertEqual(audio.SDL_AUDIO_BITSIZE(audio.AUDIO_S16), 16)
+        self.assertEqual(audio.SDL_AUDIO_BITSIZE(audio.AUDIO_S32LSB), 32)
+        self.assertEqual(audio.SDL_AUDIO_BITSIZE(audio.AUDIO_S32MSB), 32)
+        self.assertEqual(audio.SDL_AUDIO_BITSIZE(audio.AUDIO_S32), 32)
+        self.assertEqual(audio.SDL_AUDIO_BITSIZE(audio.AUDIO_F32LSB), 32)
+        self.assertEqual(audio.SDL_AUDIO_BITSIZE(audio.AUDIO_F32MSB), 32)
+        self.assertEqual(audio.SDL_AUDIO_BITSIZE(audio.AUDIO_F32), 32)
 
     def test_SDL_AUDIO_ISFLOAT(self):
         self.assertFalse(audio.SDL_AUDIO_ISFLOAT(audio.AUDIO_U8))
+        self.assertFalse(audio.SDL_AUDIO_ISFLOAT(audio.AUDIO_S8))
+        self.assertFalse(audio.SDL_AUDIO_ISFLOAT(audio.AUDIO_U16LSB))
+        self.assertFalse(audio.SDL_AUDIO_ISFLOAT(audio.AUDIO_S16LSB))
+        self.assertFalse(audio.SDL_AUDIO_ISFLOAT(audio.AUDIO_U16MSB))
+        self.assertFalse(audio.SDL_AUDIO_ISFLOAT(audio.AUDIO_S16MSB))
+        self.assertFalse(audio.SDL_AUDIO_ISFLOAT(audio.AUDIO_U16))
+        self.assertFalse(audio.SDL_AUDIO_ISFLOAT(audio.AUDIO_S16))
+        self.assertFalse(audio.SDL_AUDIO_ISFLOAT(audio.AUDIO_S32LSB))
+        self.assertFalse(audio.SDL_AUDIO_ISFLOAT(audio.AUDIO_S32MSB))
+        self.assertFalse(audio.SDL_AUDIO_ISFLOAT(audio.AUDIO_S32))
+        self.assertTrue(audio.SDL_AUDIO_ISFLOAT(audio.AUDIO_F32LSB))
         self.assertTrue(audio.SDL_AUDIO_ISFLOAT(audio.AUDIO_F32MSB))
+        self.assertTrue(audio.SDL_AUDIO_ISFLOAT(audio.AUDIO_F32))
 
     def test_SDL_AUDIO_ISBIGENDIAN(self):
+        self.assertFalse(audio.SDL_AUDIO_ISBIGENDIAN(audio.AUDIO_U8))
+        self.assertFalse(audio.SDL_AUDIO_ISBIGENDIAN(audio.AUDIO_S8))
         self.assertFalse(audio.SDL_AUDIO_ISBIGENDIAN(audio.AUDIO_U16LSB))
+        self.assertFalse(audio.SDL_AUDIO_ISBIGENDIAN(audio.AUDIO_S16LSB))
+        self.assertTrue(audio.SDL_AUDIO_ISBIGENDIAN(audio.AUDIO_U16MSB))
+        self.assertTrue(audio.SDL_AUDIO_ISBIGENDIAN(audio.AUDIO_S16MSB))
+        self.assertFalse(audio.SDL_AUDIO_ISBIGENDIAN(audio.AUDIO_U16))
+        self.assertFalse(audio.SDL_AUDIO_ISBIGENDIAN(audio.AUDIO_S16))
+        self.assertFalse(audio.SDL_AUDIO_ISBIGENDIAN(audio.AUDIO_S32LSB))
         self.assertTrue(audio.SDL_AUDIO_ISBIGENDIAN(audio.AUDIO_S32MSB))
+        self.assertFalse(audio.SDL_AUDIO_ISBIGENDIAN(audio.AUDIO_S32))
+        self.assertFalse(audio.SDL_AUDIO_ISBIGENDIAN(audio.AUDIO_F32LSB))
+        self.assertTrue(audio.SDL_AUDIO_ISBIGENDIAN(audio.AUDIO_F32MSB))
+        self.assertFalse(audio.SDL_AUDIO_ISBIGENDIAN(audio.AUDIO_F32))
 
     def test_SDL_AUDIO_ISSIGNED(self):
         self.assertFalse(audio.SDL_AUDIO_ISSIGNED(audio.AUDIO_U8))
         self.assertTrue(audio.SDL_AUDIO_ISSIGNED(audio.AUDIO_S8))
+        self.assertFalse(audio.SDL_AUDIO_ISSIGNED(audio.AUDIO_U16LSB))
+        self.assertTrue(audio.SDL_AUDIO_ISSIGNED(audio.AUDIO_S16LSB))
+        self.assertFalse(audio.SDL_AUDIO_ISSIGNED(audio.AUDIO_U16MSB))
+        self.assertTrue(audio.SDL_AUDIO_ISSIGNED(audio.AUDIO_S16MSB))
+        self.assertFalse(audio.SDL_AUDIO_ISSIGNED(audio.AUDIO_U16))
+        self.assertTrue(audio.SDL_AUDIO_ISSIGNED(audio.AUDIO_S16))
+        self.assertTrue(audio.SDL_AUDIO_ISSIGNED(audio.AUDIO_S32LSB))
+        self.assertTrue(audio.SDL_AUDIO_ISSIGNED(audio.AUDIO_S32MSB))
+        self.assertTrue(audio.SDL_AUDIO_ISSIGNED(audio.AUDIO_S32))
+        self.assertTrue(audio.SDL_AUDIO_ISSIGNED(audio.AUDIO_F32LSB))
+        self.assertTrue(audio.SDL_AUDIO_ISSIGNED(audio.AUDIO_F32MSB))
+        self.assertTrue(audio.SDL_AUDIO_ISSIGNED(audio.AUDIO_F32))
 
     def test_SDL_AUDIO_ISINT(self):
         self.assertTrue(audio.SDL_AUDIO_ISINT(audio.AUDIO_U8))
+        self.assertTrue(audio.SDL_AUDIO_ISINT(audio.AUDIO_S8))
+        self.assertTrue(audio.SDL_AUDIO_ISINT(audio.AUDIO_U16LSB))
+        self.assertTrue(audio.SDL_AUDIO_ISINT(audio.AUDIO_S16LSB))
+        self.assertTrue(audio.SDL_AUDIO_ISINT(audio.AUDIO_U16MSB))
+        self.assertTrue(audio.SDL_AUDIO_ISINT(audio.AUDIO_S16MSB))
+        self.assertTrue(audio.SDL_AUDIO_ISINT(audio.AUDIO_U16))
+        self.assertTrue(audio.SDL_AUDIO_ISINT(audio.AUDIO_S16))
+        self.assertTrue(audio.SDL_AUDIO_ISINT(audio.AUDIO_S32LSB))
+        self.assertTrue(audio.SDL_AUDIO_ISINT(audio.AUDIO_S32MSB))
+        self.assertTrue(audio.SDL_AUDIO_ISINT(audio.AUDIO_S32))
+        self.assertFalse(audio.SDL_AUDIO_ISINT(audio.AUDIO_F32LSB))
         self.assertFalse(audio.SDL_AUDIO_ISINT(audio.AUDIO_F32MSB))
+        self.assertFalse(audio.SDL_AUDIO_ISINT(audio.AUDIO_F32))
 
     def test_SDL_AUDIO_ISLITTLEENDIAN(self):
+        self.assertTrue(audio.SDL_AUDIO_ISLITTLEENDIAN(audio.AUDIO_U8))
+        self.assertTrue(audio.SDL_AUDIO_ISLITTLEENDIAN(audio.AUDIO_S8))
         self.assertTrue(audio.SDL_AUDIO_ISLITTLEENDIAN(audio.AUDIO_U16LSB))
+        self.assertTrue(audio.SDL_AUDIO_ISLITTLEENDIAN(audio.AUDIO_S16LSB))
+        self.assertFalse(audio.SDL_AUDIO_ISLITTLEENDIAN(audio.AUDIO_U16MSB))
+        self.assertFalse(audio.SDL_AUDIO_ISLITTLEENDIAN(audio.AUDIO_S16MSB))
+        self.assertTrue(audio.SDL_AUDIO_ISLITTLEENDIAN(audio.AUDIO_U16))
+        self.assertTrue(audio.SDL_AUDIO_ISLITTLEENDIAN(audio.AUDIO_S16))
+        self.assertTrue(audio.SDL_AUDIO_ISLITTLEENDIAN(audio.AUDIO_S32LSB))
         self.assertFalse(audio.SDL_AUDIO_ISLITTLEENDIAN(audio.AUDIO_S32MSB))
+        self.assertTrue(audio.SDL_AUDIO_ISLITTLEENDIAN(audio.AUDIO_S32))
+        self.assertTrue(audio.SDL_AUDIO_ISLITTLEENDIAN(audio.AUDIO_F32LSB))
+        self.assertFalse(audio.SDL_AUDIO_ISLITTLEENDIAN(audio.AUDIO_F32MSB))
+        self.assertTrue(audio.SDL_AUDIO_ISLITTLEENDIAN(audio.AUDIO_F32))
 
     def test_SDL_AUDIO_ISUNSIGNED(self):
         self.assertTrue(audio.SDL_AUDIO_ISUNSIGNED(audio.AUDIO_U8))
         self.assertFalse(audio.SDL_AUDIO_ISUNSIGNED(audio.AUDIO_S8))
+        self.assertTrue(audio.SDL_AUDIO_ISUNSIGNED(audio.AUDIO_U16LSB))
+        self.assertFalse(audio.SDL_AUDIO_ISUNSIGNED(audio.AUDIO_S16LSB))
+        self.assertTrue(audio.SDL_AUDIO_ISUNSIGNED(audio.AUDIO_U16MSB))
+        self.assertFalse(audio.SDL_AUDIO_ISUNSIGNED(audio.AUDIO_S16MSB))
+        self.assertTrue(audio.SDL_AUDIO_ISUNSIGNED(audio.AUDIO_U16))
+        self.assertFalse(audio.SDL_AUDIO_ISUNSIGNED(audio.AUDIO_S16))
+        self.assertFalse(audio.SDL_AUDIO_ISUNSIGNED(audio.AUDIO_S32LSB))
+        self.assertFalse(audio.SDL_AUDIO_ISUNSIGNED(audio.AUDIO_S32MSB))
+        self.assertFalse(audio.SDL_AUDIO_ISUNSIGNED(audio.AUDIO_S32))
+        self.assertFalse(audio.SDL_AUDIO_ISUNSIGNED(audio.AUDIO_F32LSB))
+        self.assertFalse(audio.SDL_AUDIO_ISUNSIGNED(audio.AUDIO_F32MSB))
+        self.assertFalse(audio.SDL_AUDIO_ISUNSIGNED(audio.AUDIO_F32))
 
     @unittest.skip("not implemented")
     def test_SDL_AudioSpec(self):