Loading media/jni/soundpool/android_media_SoundPool.cpp +8 −5 Original line number Diff line number Diff line Loading @@ -86,7 +86,7 @@ public: } // Retrieves the associated object, returns nullValue T if not available. T get(JNIEnv *env, jobject thiz) { T get(JNIEnv *env, jobject thiz) const { std::lock_guard lg(mLock); // NOLINTNEXTLINE(performance-no-int-to-ptr) auto ptr = reinterpret_cast<T*>(env->GetLongField(thiz, mFieldId)); Loading Loading @@ -167,8 +167,10 @@ private: // is possible by checking if the WeakGlobalRef is null equivalent. auto& getSoundPoolManager() { static ObjectManager<std::shared_ptr<SoundPool>> soundPoolManager(fields.mNativeContext); return soundPoolManager; // never-delete singleton static auto soundPoolManager = new ObjectManager<std::shared_ptr<SoundPool>>(fields.mNativeContext); return *soundPoolManager; } inline auto getSoundPool(JNIEnv *env, jobject thiz) { Loading Loading @@ -274,8 +276,9 @@ static_assert(std::is_same_v<JWeakValue*, jweak>); auto& getSoundPoolJavaRefManager() { // Note this can store shared_ptrs to either jweak and jobject, // as the underlying type is identical. static ConcurrentHashMap<SoundPool *, std::shared_ptr<JWeakValue>> concurrentHashMap; return concurrentHashMap; static auto concurrentHashMap = new ConcurrentHashMap<SoundPool *, std::shared_ptr<JWeakValue>>(); return *concurrentHashMap; } // make_shared_globalref_from_localref() creates a sharable Java global Loading Loading
media/jni/soundpool/android_media_SoundPool.cpp +8 −5 Original line number Diff line number Diff line Loading @@ -86,7 +86,7 @@ public: } // Retrieves the associated object, returns nullValue T if not available. T get(JNIEnv *env, jobject thiz) { T get(JNIEnv *env, jobject thiz) const { std::lock_guard lg(mLock); // NOLINTNEXTLINE(performance-no-int-to-ptr) auto ptr = reinterpret_cast<T*>(env->GetLongField(thiz, mFieldId)); Loading Loading @@ -167,8 +167,10 @@ private: // is possible by checking if the WeakGlobalRef is null equivalent. auto& getSoundPoolManager() { static ObjectManager<std::shared_ptr<SoundPool>> soundPoolManager(fields.mNativeContext); return soundPoolManager; // never-delete singleton static auto soundPoolManager = new ObjectManager<std::shared_ptr<SoundPool>>(fields.mNativeContext); return *soundPoolManager; } inline auto getSoundPool(JNIEnv *env, jobject thiz) { Loading Loading @@ -274,8 +276,9 @@ static_assert(std::is_same_v<JWeakValue*, jweak>); auto& getSoundPoolJavaRefManager() { // Note this can store shared_ptrs to either jweak and jobject, // as the underlying type is identical. static ConcurrentHashMap<SoundPool *, std::shared_ptr<JWeakValue>> concurrentHashMap; return concurrentHashMap; static auto concurrentHashMap = new ConcurrentHashMap<SoundPool *, std::shared_ptr<JWeakValue>>(); return *concurrentHashMap; } // make_shared_globalref_from_localref() creates a sharable Java global Loading