def test_SDL_GetAudioDeviceName(self): devices = {} # Reset audio subsystem SDL_Quit() SDL_Init(0) for index in range(audio.SDL_GetNumAudioDrivers()): # Get input/output device names for each audio driver drivername = audio.SDL_GetAudioDriver(index) os.environ["SDL_AUDIODRIVER"] = drivername.decode("utf-8") # Need to reinitialize subsystem for each driver SDL_InitSubSystem(SDL_INIT_AUDIO) driver = audio.SDL_GetCurrentAudioDriver() if driver is not None: driver = driver.decode("utf-8") devices[driver] = {'input': [], 'output': []} outnum = audio.SDL_GetNumAudioDevices(False) innum = audio.SDL_GetNumAudioDevices(True) for x in range(outnum): name = audio.SDL_GetAudioDeviceName(x, False) assert name is not None devices[driver]['output'].append(name.decode('utf-8')) for x in range(innum): name = audio.SDL_GetAudioDeviceName(x, True) assert name is not None devices[driver]['input'].append(name.decode('utf-8')) SDL_QuitSubSystem(SDL_INIT_AUDIO) print("Available audio drivers and devices:") for driver in devices.keys(): print(driver) print(" - input: {0}".format(str(devices[driver]['input']))) print(" - output: {0}".format(str(devices[driver]['output'])))
def test_SDL_GetAudioDriver(self): founddummy = False drivercount = audio.SDL_GetNumAudioDrivers() for index in range(drivercount): drivername = audio.SDL_GetAudioDriver(index) assert isinstance(drivername, (str, bytes)) if drivername == b"dummy": founddummy = True assert founddummy, "could not find dummy driver" with pytest.raises((ctypes.ArgumentError, TypeError)): audio.SDL_GetAudioDriver("Test") with pytest.raises((ctypes.ArgumentError, TypeError)): audio.SDL_GetAudioDriver(None)
def test_SDL_GetCurrentAudioDriver(self): success = 0 for index in range(audio.SDL_GetNumAudioDrivers()): drivername = audio.SDL_GetAudioDriver(index) os.environ["SDL_AUDIODRIVER"] = drivername.decode("utf-8") # Certain drivers fail without bringing up the correct # return value, such as the esd, if it is not running. SDL_InitSubSystem(SDL_INIT_AUDIO) driver = audio.SDL_GetCurrentAudioDriver() # Do not handle wrong return values. if driver is not None: self.assertEqual(drivername, driver) success += 1 SDL_QuitSubSystem(SDL_INIT_AUDIO) self.assertGreaterEqual(success, 1, "Could not initialize any sound driver")
def test_SDL_GetAudioDriver(self): founddummy = False drivercount = audio.SDL_GetNumAudioDrivers() for index in range(drivercount): drivername = audio.SDL_GetAudioDriver(index) self.assertIsInstance(drivername, (str, bytes)) if drivername == b"dummy": founddummy = True self.assertTrue(founddummy, "could not find dummy driver") # self.assertRaises(SDLError, audio.SDL_GetAudioDriver, -1) # self.assertRaises(SDLError, audio.get_audio_driver, # drivercount + 1) self.assertRaises((ctypes.ArgumentError, TypeError), audio.SDL_GetAudioDriver, "Test") self.assertRaises((ctypes.ArgumentError, TypeError), audio.SDL_GetAudioDriver, None)
def test_SDL_GetCurrentAudioDriver(self): success = 0 # Reset audio subsystem SDL_Quit() SDL_Init(0) for index in range(audio.SDL_GetNumAudioDrivers()): drivername = audio.SDL_GetAudioDriver(index) os.environ["SDL_AUDIODRIVER"] = drivername.decode("utf-8") # Certain drivers fail without bringing up the correct # return value, such as the esd, if it is not running. SDL_InitSubSystem(SDL_INIT_AUDIO) driver = audio.SDL_GetCurrentAudioDriver() SDL_QuitSubSystem(SDL_INIT_AUDIO) # Do not handle wrong return values. if driver is not None: assert drivername == driver success += 1 assert success >= 1
def test_SDL_GetAudioDriver(self): if SDL_InitSubSystem(SDL_INIT_AUDIO) != 0: self.skipTest('Audio subsystem not supported') founddummy = False drivercount = audio.SDL_GetNumAudioDrivers() for index in range(drivercount): drivername = audio.SDL_GetAudioDriver(index) self.assertIsInstance(drivername, (str, bytes)) if drivername == b"dummy": founddummy = True self.assertTrue(founddummy, "could not find dummy driver") # self.assertRaises(SDLError, audio.SDL_GetAudioDriver, -1) # self.assertRaises(SDLError, audio.get_audio_driver, # drivercount + 1) self.assertRaises((ctypes.ArgumentError, TypeError), audio.SDL_GetAudioDriver, "Test") self.assertRaises((ctypes.ArgumentError, TypeError), audio.SDL_GetAudioDriver, None) SDL_QuitSubSystem(SDL_INIT_AUDIO)
def test_SDL_GetNumAudioDrivers(self): count = audio.SDL_GetNumAudioDrivers() assert count >= 1
def test_SDL_GetNumAudioDrivers(self): count = audio.SDL_GetNumAudioDrivers() self.assertGreaterEqual(count, 1)
def test_SDL_GetNumAudioDrivers(self): if SDL_InitSubSystem(SDL_INIT_AUDIO) != 0: self.skipTest('Audio subsystem not supported') count = audio.SDL_GetNumAudioDrivers() self.assertGreaterEqual(count, 1) SDL_QuitSubSystem(SDL_INIT_AUDIO)