From b296e4bfdb452cd76822f032188b4f05073adc86 Mon Sep 17 00:00:00 2001 From: Stephen Sinclair Date: Thu, 9 Aug 2018 15:55:57 -0400 Subject: [PATCH] Remove the compiledApis vector. --- RtAudio.cpp | 31 +++++++++++-------------------- RtAudio.h | 11 ----------- 2 files changed, 11 insertions(+), 31 deletions(-) diff --git a/RtAudio.cpp b/RtAudio.cpp index 7200d1e..4e75d68 100644 --- a/RtAudio.cpp +++ b/RtAudio.cpp @@ -152,12 +152,6 @@ extern "C" const unsigned int rtaudio_num_compiled_apis = sizeof(rtaudio_compiled_apis)/sizeof(rtaudio_compiled_apis[0])-1; } -static const std::vector init_compiledApis() { - return std::vector( - rtaudio_compiled_apis, rtaudio_compiled_apis + rtaudio_num_compiled_apis); -} -const std::vector RtAudio::compiledApis(init_compiledApis()); - // This is a compile-time check that rtaudio_num_api_names == RtAudio::NUM_APIS. // If the build breaks here, check that they match. template class StaticAssert { private: StaticAssert() {} }; @@ -168,19 +162,16 @@ class StaticAssertions { StaticAssertions() { void RtAudio :: getCompiledApi( std::vector &apis ) { - apis = compiledApis; -} - -const std::vector& RtAudio :: getCompiledApis() -{ - return compiledApis; + apis = std::vector(rtaudio_compiled_apis, + rtaudio_compiled_apis + rtaudio_num_compiled_apis); } const std::string RtAudio :: getCompiledApiName( RtAudio::Api api ) { if (api < 0 || api > RtAudio::NUM_APIS - || (std::find(RtAudio::compiledApis.begin(), - RtAudio::compiledApis.end(), api) == RtAudio::compiledApis.end())) + || (std::find(rtaudio_compiled_apis, + rtaudio_compiled_apis+rtaudio_num_compiled_apis, + api) == rtaudio_compiled_apis+rtaudio_num_compiled_apis)) return ""; return rtaudio_api_names[api][0]; } @@ -188,8 +179,9 @@ const std::string RtAudio :: getCompiledApiName( RtAudio::Api api ) const std::string RtAudio :: getCompiledApiDisplayName( RtAudio::Api api ) { if (api < 0 || api > RtAudio::NUM_APIS - || (std::find(RtAudio::compiledApis.begin(), - RtAudio::compiledApis.end(), api) == RtAudio::compiledApis.end())) + || (std::find(rtaudio_compiled_apis, + rtaudio_compiled_apis+rtaudio_num_compiled_apis, + api) == rtaudio_compiled_apis+rtaudio_num_compiled_apis)) return "Unknown"; return rtaudio_api_names[api][1]; } @@ -197,10 +189,9 @@ const std::string RtAudio :: getCompiledApiDisplayName( RtAudio::Api api ) RtAudio::Api RtAudio :: getCompiledApiByName( const std::string &name ) { unsigned int i=0; - std::vector::const_iterator it; - for (it = compiledApis.begin(); it != compiledApis.end(); ++it, ++i) - if (name == rtaudio_api_names[*it][0]) - return *it; + for (i = 0; i < rtaudio_num_compiled_apis; ++i) + if (name == rtaudio_api_names[rtaudio_compiled_apis[i]][0]) + return rtaudio_compiled_apis[i]; return RtAudio::UNSPECIFIED; } diff --git a/RtAudio.h b/RtAudio.h index 5b71fe8..9976541 100644 --- a/RtAudio.h +++ b/RtAudio.h @@ -402,14 +402,6 @@ class RTAUDIO_DLL_PUBLIC RtAudio */ static void getCompiledApi( std::vector &apis ); - //! A static function to determine the available compiled audio APIs. - /*! - The values returned in the std::vector can be compared against - the enumerated list values. Note that there can be more than one - API compiled for certain operating systems. - */ - static const std::vector& getCompiledApis(); - //! Return the name of a specified compiled audio API. /*! This obtains a short lower-case name used for identification purposes. @@ -619,9 +611,6 @@ class RTAUDIO_DLL_PUBLIC RtAudio protected: - //! Storage for compiled API list - static const std::vector compiledApis; - void openRtApi( RtAudio::Api api ); RtApi *rtapi_; };