Example #1
0
 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'])))
Example #2
0
 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")
Example #3
0
 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