def test_SDL_OpenCloseAudio(self): fmt = audio.AUDIO_F32 if sys.platform == "darwin" else audio.AUDIO_U16SYS reqspec = audio.SDL_AudioSpec(44100, fmt, 2, 1024) spec = audio.SDL_AudioSpec(0, 0, 0, 0) ret = audio.SDL_OpenAudio(reqspec, ctypes.byref(spec)) assert ret == 0 assert spec.format == reqspec.format assert spec.freq == reqspec.freq assert spec.channels == reqspec.channels audio.SDL_CloseAudio()
def test_SDL_OpenAudio(self): os.environ["SDL_AUDIODRIVER"] = "dummy" SDL_InitSubSystem(SDL_INIT_AUDIO) reqspec = audio.SDL_AudioSpec(44100, audio.AUDIO_U16SYS, 2, 8192, self.audiocallback, None) spec = audio.SDL_AudioSpec(0, 0, 0, 0) ret = audio.SDL_OpenAudio(reqspec, ctypes.byref(spec)) self.assertEqual(ret, 0) self.assertEqual(spec.format, reqspec.format) self.assertEqual(spec.freq, reqspec.freq) self.assertEqual(spec.channels, reqspec.channels) audio.SDL_CloseAudio() SDL_QuitSubSystem(SDL_INIT_AUDIO)
def test_SDL_OpenCloseAudioDevice(self): os.environ["SDL_AUDIODRIVER"] = "dummy" SDL_InitSubSystem(SDL_INIT_AUDIO) reqspec = audio.SDL_AudioSpec(44100, audio.AUDIO_U16SYS, 2, 8192, self.audiocallback, None) outnum = audio.SDL_GetNumAudioDevices(0) for x in range(outnum): spec = audio.SDL_AudioSpec() name = audio.SDL_GetAudioDeviceName(x, 0) self.assertIsNotNone(name) deviceid = audio.SDL_OpenAudioDevice(None, 0, reqspec, ctypes.byref(spec), 1) 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.SDL_CloseAudioDevice(deviceid) SDL_QuitSubSystem(SDL_INIT_AUDIO)
def test_SDL_OpenCloseAudioDevice(self): #TODO: Add tests for callback fmt = audio.AUDIO_F32 if sys.platform == "darwin" else audio.AUDIO_U16SYS reqspec = audio.SDL_AudioSpec(44100, fmt, 2, 1024) outnum = audio.SDL_GetNumAudioDevices(0) for x in range(outnum): spec = audio.SDL_AudioSpec(0, 0, 0, 0) name = audio.SDL_GetAudioDeviceName(x, 0) assert name is not None deviceid = audio.SDL_OpenAudioDevice( name, 0, reqspec, ctypes.byref(spec), audio.SDL_AUDIO_ALLOW_ANY_CHANGE) err = SDL_GetError() assert deviceid >= 2 assert isinstance(spec, audio.SDL_AudioSpec) assert spec.format in audio.AUDIO_FORMATS assert spec.freq > 0 assert spec.channels > 0 assert spec.samples > 0 audio.SDL_CloseAudioDevice(deviceid)