# Demo: Show infos about audio support
from sdl2 import *
# show available (and actually supported) audio drivers
print('\nsupported audio drivers:')
cnt = SDL_GetNumAudioDrivers()
for i in range(cnt):
driver_name = SDL_GetAudioDriver(i)
if SDL_AudioInit(driver_name):
continue
else:
print('- '+driver_name.decode())
SDL_AudioQuit()
# result:
#- pulseaudio
#- dsp
#- disk
#- dummy
# Initialize SDL2
SDL_Init(SDL_INIT_AUDIO)
# show available audio devices
print('\navailable audio devices:')
cnt = SDL_GetNumAudioDevices(0)
for i in range(cnt):
print('- '+SDL_GetAudioDeviceName(i, 0).decode())
print('\n')
# result:
#- bcm2835 ALSA Analog Stereo
SDL_Quit()