-
Notifications
You must be signed in to change notification settings - Fork 322
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add getDeviceHandle() to expose client-specific structs.
In cases where the caller really needs access to the API-specific handle (e.g. jack_client_t*), then it can be returned in a derived struct. Since this means that API headers must be included before RtAudio.h, it is not enabled by default; the caller must include them him/herself and define RTAUDIO_API_SPECIFIC, or RTAUDIO_API_SPECIFIC_JACK, etc., before including RtAudio.h. Then, getDeviceHandle() returns a pointer that can be safely dynamic_cast<> so that if there is an API mismatch, nullptr is returned. This commit implements it for Jack and Pulse Audio only! Example: #include <jack/jack.h> #define RTAUDIO_API_SPECIFIC_JACK #include <RtAudio.h> ... RtAudio audio(RtAudio::UNIX_JACK); .. after openStream RtAudioClientHandle *h = audio.getClientHandle(); RtAudioClientHandleJack *h_jack = dynamic_cast<RtAudioClientHandleJack*>(h); if (h_jack) { .. my_function_needing_jack_client_t(h_jack.client); } Note that the above code will not crash if RtAudio::LINUX_PULSE was selected, and only call Jack-specific functions if indeed Jack is the current API.
- Loading branch information
Showing
2 changed files
with
147 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.