diff --git a/README.md b/README.md index 28e41da1..a85c6d0f 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ RtAudio is a set of C++ classes that provides a common API (Application Programm RtAudio incorporates the concept of audio streams, which represent audio output (playback) and/or input (recording). Available audio devices and their capabilities can be enumerated and then specified when opening a stream. Where applicable, multiple API support can be compiled and a particular API specified when creating an RtAudio instance. See the \ref apinotes section for information specific to each of the supported audio APIs. -RtAudio is also offered as a module, which is enabled with `RTAUDIO_BUILD_MODULES`, and is accessed with `import rt.audio;`. Namespaces are inlined, so classes can be accessed through namespace `rt::audio` or through the global namespace (for example, `rt::audio::RtApi` and `::RtApi` are both valid). +RtAudio is also offered as a module, which is enabled with `RTAUDIO_BUILD_MODULES`, and is accessed with `import rt.audio;`. Namespaces are implicitly imported (unless disabled with `RTAUDIO_USE_NAMESPACE`), so classes can be accessed through namespace `rt::audio` or through the global namespace (for example, `rt::audio::RtApi` and `::RtApi` are both valid). ## Building diff --git a/RtAudio.cpp b/RtAudio.cpp index 8e394be8..b7dc15a9 100644 --- a/RtAudio.cpp +++ b/RtAudio.cpp @@ -55,6 +55,8 @@ #include #endif +using namespace rt::audio; + // Static variable definitions. const unsigned int RtApi::MAX_SAMPLE_RATES = 14; const unsigned int RtApi::SAMPLE_RATES[] = { diff --git a/RtAudio.h b/RtAudio.h index dbf4f433..446d8793 100644 --- a/RtAudio.h +++ b/RtAudio.h @@ -85,8 +85,7 @@ #include #include -inline namespace rt { -inline namespace audio { +namespace rt::audio { /*! \typedef typedef unsigned long RtAudioFormat; \brief RtAudio data format type. @@ -651,7 +650,6 @@ class RTAUDIO_DLL_PUBLIC RtAudio std::shared_ptr rtapi_; }; -} } // Operating system dependent thread functionality. @@ -676,12 +674,10 @@ inline namespace audio { // Using pthread library for various flavors of unix. #include -inline namespace rt { -inline namespace audio { +namespace rt::audio { typedef pthread_t ThreadHandle; typedef pthread_mutex_t StreamMutex; } -} #endif @@ -694,8 +690,7 @@ inline namespace audio { #endif -inline namespace rt { -inline namespace audio { +namespace rt::audio { // This global structure type is used to pass callback information // between the private RtAudio stream structure and global callback @@ -755,7 +750,6 @@ class S24 { }; #pragma pack(pop) -} } #if defined( HAVE_GETTIMEOFDAY ) @@ -764,8 +758,7 @@ class S24 { #include -inline namespace rt { -inline namespace audio { +namespace rt::audio { class RTAUDIO_DLL_PUBLIC RtApi { @@ -952,11 +945,13 @@ inline void RtAudio :: setStreamTime( double time ) { return rtapi_->setStreamTi inline void RtAudio :: setErrorCallback( RtAudioErrorCallback errorCallback ) { rtapi_->setErrorCallback( errorCallback ); } inline void RtAudio :: showWarnings( bool value ) { rtapi_->showWarnings( value ); } -} } #endif +#ifndef RTAUDIO_USE_NAMESPACE +using namespace rt::audio; +#endif // Indentation settings for Vim and Emacs // diff --git a/modules/RtAudio.cppm b/modules/RtAudio.cppm index d3774dfa..f60da68b 100644 --- a/modules/RtAudio.cppm +++ b/modules/RtAudio.cppm @@ -4,13 +4,7 @@ module; export module rt.audio; -export -#ifdef RTAUDIO_USE_NAMESPACE -inline namespace rt { -inline namespace audio { -#else -namespace rt::audio { -#endif +export namespace rt::audio { using rt::audio::RtAudioFormat; using rt::audio::RtAudioStreamFlags; using rt::audio::RtAudioStreamStatus; @@ -24,6 +18,7 @@ namespace rt::audio { using rt::audio::CallbackInfo; using rt::audio::S24; } -#ifdef RTAUDIO_USE_NAMESPACE -} + +#ifndef RTAUDIO_USE_NAMESPACE +using namespace rt::audio; #endif