Пример #1
0
    def test_get_audio_device_name(self):
        os.environ["SDL_AUDIODRIVER"] = "dummy"
        sdl.init_subsystem(sdl.SDL_INIT_AUDIO)
        outnum = audio.get_num_audio_devices()
        for x in range(outnum):
            name = audio.get_audio_device_name(x)
            self.assertIsNotNone(name)
        innum = audio.get_num_audio_devices(True)
        for x in range(innum):
            name = audio.get_audio_device_name(x, True)
            self.assertIsNotNone(name)
        self.assertRaises(sdl.SDLError, audio.get_audio_device_name, -1)
        self.assertRaises(sdl.SDLError, audio.get_audio_device_name, -1, True)
        sdl.quit_subsystem(sdl.SDL_INIT_AUDIO)

        self.assertRaises(sdl.SDLError, audio.get_audio_device_name, 0)
        self.assertRaises(sdl.SDLError, audio.get_audio_device_name, 0, True)
Пример #2
0
 def test_open_close_audio_device(self):
     os.environ["SDL_AUDIODRIVER"] = "dummy"
     sdl.init_subsystem(sdl.SDL_INIT_AUDIO)
     reqspec = audio.SDL_AudioSpec(44100, audio.AUDIO_U16SYS, 2, 8192,
                                   self.audiocallback, None)
     outnum = audio.get_num_audio_devices()
     for x in range(outnum):
         name = audio.get_audio_device_name(x)
         self.assertIsNotNone(name)
         deviceid, spec = audio.open_audio_device(name, False, reqspec, 0)
         self.assertGreaterEqual(deviceid, 2)
         self.assertIsInstance(spec, audio.SDL_AudioSpec)
         self.assertEqual(spec.format, reqspec.format)
         self.assertEqual(spec.freq, reqspec.freq)
         self.assertEqual(spec.channels, reqspec.channels)
         audio.close_audio_device(deviceid)
     sdl.quit_subsystem(sdl.SDL_INIT_AUDIO)