diff options
Diffstat (limited to 'src/aaudio/AAudioLoader.cpp')
-rw-r--r-- | src/aaudio/AAudioLoader.cpp | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/src/aaudio/AAudioLoader.cpp b/src/aaudio/AAudioLoader.cpp index 064633c6..ec97a26e 100644 --- a/src/aaudio/AAudioLoader.cpp +++ b/src/aaudio/AAudioLoader.cpp @@ -24,10 +24,17 @@ namespace oboe { AAudioLoader::~AAudioLoader() { - if (mLibHandle != nullptr) { - dlclose(mLibHandle); - mLibHandle = nullptr; - } + // Issue 360: thread_local variables with non-trivial destructors + // will cause segfaults if the containing library is dlclose()ed on + // devices running M or newer, or devices before M when using a static STL. + // The simple workaround is to not call dlclose. + // https://github.com/android/ndk/wiki/Changelog-r22#known-issues + // + // The libaaudio and libaaudioclient do not use thread_local. + // But, to be safe, we should avoid dlclose() if possible. + // Because AAudioLoader is a static Singleton, we can safely skip + // calling dlclose() without causing a resource leak. + LOGI("%s() dlclose(%s) not called, OK", __func__, LIB_AAUDIO_NAME); } AAudioLoader* AAudioLoader::getInstance() { @@ -90,8 +97,6 @@ int AAudioLoader::open() { stream_getTimestamp = load_I_PSKPLPL("AAudioStream_getTimestamp"); - stream_isMMapUsed = load_B_PS("AAudioStream_isMMapUsed"); - stream_getChannelCount = load_I_PS("AAudioStream_getChannelCount"); if (stream_getChannelCount == nullptr) { // Use old alias if needed. @@ -304,7 +309,6 @@ AAudioLoader::signature_I_PSKPLPL AAudioLoader::load_I_PSKPLPL(const char *funct == AAUDIO_PERFORMANCE_MODE_POWER_SAVING, ERRMSG); static_assert((int32_t)PerformanceMode::LowLatency == AAUDIO_PERFORMANCE_MODE_LOW_LATENCY, ERRMSG); -#endif // The aaudio_ usage, content and input_preset types were added in NDK 17, // which is the first version to support Android Pie (API 28). @@ -343,6 +347,9 @@ AAudioLoader::signature_I_PSKPLPL AAudioLoader::load_I_PSKPLPL(const char *funct static_assert((int32_t)SessionId::None == AAUDIO_SESSION_ID_NONE, ERRMSG); static_assert((int32_t)SessionId::Allocate == AAUDIO_SESSION_ID_ALLOCATE, ERRMSG); -#endif + +#endif // __NDK_MAJOR__ >= 17 + +#endif // AAUDIO_AAUDIO_H } // namespace oboe |