X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=rtaudio_c.cpp;h=ad91babb5c68d8495f798cbd247e914915c388dd;hb=65b4b78a15349fca6d712babd637fbefedf668be;hp=090cbf90ee4bb8759c159cd9d7c1ef5256c98f86;hpb=5c69780f4bf67e26ed370cea39418b2d82df119e;p=rtaudio-cdist.git diff --git a/rtaudio_c.cpp b/rtaudio_c.cpp index 090cbf9..ad91bab 100644 --- a/rtaudio_c.cpp +++ b/rtaudio_c.cpp @@ -15,40 +15,39 @@ struct rtaudio { char errmsg[MAX_ERROR_MESSAGE_LENGTH]; }; -static const rtaudio_api_t compiled_api[] = { -#if defined(__UNIX_JACK__) - RTAUDIO_API_UNIX_JACK, -#endif -#if defined(__LINUX_ALSA__) - RTAUDIO_API_LINUX_ALSA, -#endif -#if defined(__LINUX_PULSE__) - RTAUDIO_API_LINUX_PULSE, -#endif -#if defined(__LINUX_OSS__) - RTAUDIO_API_LINUX_OSS, -#endif -#if defined(__WINDOWS_ASIO__) - RTAUDIO_API_WINDOWS_ASIO, -#endif -#if defined(__WINDOWS_WASAPI__) - RTAUDIO_API_WINDOWS_WASAPI, -#endif -#if defined(__WINDOWS_DS__) - RTAUDIO_API_WINDOWS_DS, -#endif -#if defined(__MACOSX_CORE__) - RTAUDIO_API_MACOSX_CORE, -#endif -#if defined(__RTAUDIO_DUMMY__) - RTAUDIO_API_DUMMY, -#endif - RTAUDIO_API_UNSPECIFIED, -}; - const char *rtaudio_version() { return RTAUDIO_VERSION; } -const rtaudio_api_t *rtaudio_compiled_api() { return compiled_api; } +extern "C" const RtAudio::Api rtaudio_compiled_apis[]; +const rtaudio_api_t *rtaudio_compiled_api() { + return (rtaudio_api_t *) &rtaudio_compiled_apis[0]; +} + +extern "C" const unsigned int rtaudio_num_compiled_apis; +unsigned int rtaudio_get_num_compiled_apis(void) { + return rtaudio_num_compiled_apis; +} + +extern "C" const char* rtaudio_api_names[][2]; +const char *rtaudio_api_name(rtaudio_api_t api) { + if (api < 0 || api >= RTAUDIO_API_NUM) + return NULL; + return rtaudio_api_names[api][0]; +} + +const char *rtaudio_api_display_name(rtaudio_api_t api) +{ + if (api < 0 || api >= RTAUDIO_API_NUM) + return "Unknown"; + return rtaudio_api_names[api][1]; +} + +rtaudio_api_t rtaudio_compiled_api_by_name(const char *name) { + RtAudio::Api api = RtAudio::UNSPECIFIED; + if (name) { + api = RtAudio::getCompiledApiByName(name); + } + return (rtaudio_api_t)api; +} const char *rtaudio_error(rtaudio_t audio) { if (audio->has_error) { @@ -79,7 +78,8 @@ int rtaudio_device_count(rtaudio_t audio) { } rtaudio_device_info_t rtaudio_get_device_info(rtaudio_t audio, int i) { - rtaudio_device_info_t result = {}; + rtaudio_device_info_t result; + std::memset(&result, 0, sizeof(result)); try { audio->has_error = 0; RtAudio::DeviceInfo info = audio->audio->getDeviceInfo(i);