1. # Demo: Show infos about audio support
  2.  
  3. from sdl2 import *
  4.  
  5. # show available (and actually supported) audio drivers
  6. print('\nsupported audio drivers:')
  7. cnt = SDL_GetNumAudioDrivers()
  8. for i in range(cnt):
  9.     driver_name = SDL_GetAudioDriver(i)
  10.     if SDL_AudioInit(driver_name):
  11.         continue
  12.     else:
  13.         print('- '+driver_name.decode())
  14.     SDL_AudioQuit()
  15.  
  16. # result:
  17. #- pulseaudio
  18. #- dsp
  19. #- disk
  20. #- dummy
  21.  
  22. # Initialize SDL2
  23. SDL_Init(SDL_INIT_AUDIO)
  24.  
  25. # show available audio devices
  26. print('\navailable audio devices:')
  27. cnt = SDL_GetNumAudioDevices(0)
  28. for i in range(cnt):
  29.     print('- '+SDL_GetAudioDeviceName(i, 0).decode())
  30. print('\n')
  31.  
  32. # result:
  33. #- bcm2835 ALSA Analog Stereo
  34.  
  35. SDL_Quit()
  36.  
[raw code]