This is not production ready code. There’s a lot of error checking that’s not being done. But this should at least give you an idea of how to begin using the PulseAudio asynchronous API.

To compile this program, you will need to link against the pulse library. For example, if you save this program as "pulsedevicelist.c", you should run: gcc -Wall -o pulsedevicelist pulsedevicelist.c -lpulse