Callback for connected/unconnected device using portaudio?

505 views Asked by At

Is there a callback to know when the device list is updated?

If not, is there a way of detecting it ( ideally cross platform )?

At the moment the only way i found is to re-initialise PortAudio.

ps: I tried to find "callbacks" documentation on PortAudio documentation but i failed to find it.

2

There are 2 answers

1
Ross Bencina On BEST ANSWER

Is there a callback to know when the device list is updated?

Not in the main line code. There is a branch supporting this functionality on some platforms. New contributors are always welcome to help out finish this. It is a much-needed feature.

Note that the device list is never updated between calls to Pa_Initialize() and Pa_Terminate(). This is a basic invariant of the API. The branch also supports a refresh call.

The way to do it with the current version is to use platform-specific checks, then call Pa_Terminate();Pa_Initialize(); as you suggest.

1
donjuedo On

If your OS is Linux, you can use the inotify() system call, and watch the /dev directory, or subdirectory. I don't know about Windows, though.