Created
August 7, 2018 20:17
-
-
Save jpcima/fe3c5012f1e26c3131dfac7dee387f17 to your computer and use it in GitHub Desktop.
RtAudio example using API names
This file contains hidden or 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
#include <rtaudio_c.h> | |
#include <getopt.h> | |
#include <stdio.h> | |
static void print_compiled_apis() | |
{ | |
const rtaudio_api_t *apis = rtaudio_compiled_api(); | |
while (*apis != RTAUDIO_API_UNSPECIFIED) { | |
printf(" * %s\n", rtaudio_compiled_api_name(*apis)); | |
++apis; | |
} | |
} | |
int main(int argc, char *argv[]) | |
{ | |
rtaudio_api_t api = RTAUDIO_API_UNSPECIFIED; | |
const char *desired_api = NULL; | |
printf("usage: example [-d api] [-h]\n\n"); | |
int arg; | |
while ((arg = getopt(argc, argv, "d:h")) != -1) { | |
if (arg == 'd') { | |
desired_api = optarg; | |
api = rtaudio_compiled_api_by_name(desired_api); | |
} | |
else if (arg == 'h') { | |
print_compiled_apis(); | |
return 0; | |
} | |
} | |
if (desired_api && api == RTAUDIO_API_UNSPECIFIED) { | |
printf("API unavailable '%s'.\n", desired_api); | |
print_compiled_apis(); | |
return 1; | |
} | |
rtaudio_t audiosys = rtaudio_create(api); | |
api = rtaudio_current_api(audiosys); | |
printf("Audio is open with API '%s'.\n", rtaudio_compiled_api_name(api)); | |
/* ... */ | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment