From 893134c79d8cc984e70739ffe957ffc34f6ccafd Mon Sep 17 00:00:00 2001 From: halx99 Date: Tue, 5 Apr 2022 13:58:55 +0800 Subject: [PATCH] Delete unused code --- .../src/org/cocos2dx/lib/Cocos2dxHelper.java | 32 +------------------ .../Java_org_cocos2dx_lib_Cocos2dxHelper.cpp | 25 --------------- .../Java_org_cocos2dx_lib_Cocos2dxHelper.h | 4 --- 3 files changed, 1 insertion(+), 60 deletions(-) diff --git a/core/platform/android/java/src/org/cocos2dx/lib/Cocos2dxHelper.java b/core/platform/android/java/src/org/cocos2dx/lib/Cocos2dxHelper.java index 2897091270..2ac3c489eb 100644 --- a/core/platform/android/java/src/org/cocos2dx/lib/Cocos2dxHelper.java +++ b/core/platform/android/java/src/org/cocos2dx/lib/Cocos2dxHelper.java @@ -122,37 +122,7 @@ public class Cocos2dxHelper { PackageManager pm = activity.getPackageManager(); boolean isSupportLowLatency = pm.hasSystemFeature(PackageManager.FEATURE_AUDIO_LOW_LATENCY); - - Log.d(TAG, "isSupportLowLatency:" + isSupportLowLatency); - - int sampleRate = 44100; - int bufferSizeInFrames = 192; - - if (Build.VERSION.SDK_INT >= 17) { - AudioManager am = (AudioManager) activity.getSystemService(Context.AUDIO_SERVICE); - // use reflection to remove dependence of API 17 when compiling - - // AudioManager.getProperty(AudioManager.PROPERTY_OUTPUT_SAMPLE_RATE); - final Class audioManagerClass = AudioManager.class; - Object[] parameters = new Object[]{Cocos2dxReflectionHelper.getConstantValue(audioManagerClass, "PROPERTY_OUTPUT_SAMPLE_RATE")}; - final String strSampleRate = Cocos2dxReflectionHelper.invokeInstanceMethod(am, "getProperty", new Class[]{String.class}, parameters); - - // AudioManager.getProperty(AudioManager.PROPERTY_OUTPUT_FRAMES_PER_BUFFER); - parameters = new Object[]{Cocos2dxReflectionHelper.getConstantValue(audioManagerClass, "PROPERTY_OUTPUT_FRAMES_PER_BUFFER")}; - final String strBufferSizeInFrames = Cocos2dxReflectionHelper.invokeInstanceMethod(am, "getProperty", new Class[]{String.class}, parameters); - - try { - sampleRate = Integer.parseInt(strSampleRate); - bufferSizeInFrames = Integer.parseInt(strBufferSizeInFrames); - } catch (NumberFormatException e) { - Log.e(TAG, "parseInt failed", e); - } - Log.d(TAG, "sampleRate: " + sampleRate + ", framesPerBuffer: " + bufferSizeInFrames); - } else { - Log.d(TAG, "android version is lower than 17"); - } - - nativeSetAudioDeviceInfo(isSupportLowLatency, sampleRate, bufferSizeInFrames); + Log.d(TAG, String.format("android version is %d, isSupportLowLatency: %s", Build.VERSION.SDK_INT, isSupportLowLatency ? "true" : "false") ); final ApplicationInfo applicationInfo = activity.getApplicationInfo(); diff --git a/core/platform/android/jni/Java_org_cocos2dx_lib_Cocos2dxHelper.cpp b/core/platform/android/jni/Java_org_cocos2dx_lib_Cocos2dxHelper.cpp index 63d0d8e93a..684aee3e80 100644 --- a/core/platform/android/jni/Java_org_cocos2dx_lib_Cocos2dxHelper.cpp +++ b/core/platform/android/jni/Java_org_cocos2dx_lib_Cocos2dxHelper.cpp @@ -42,9 +42,6 @@ static const char* className = "org.cocos2dx.lib.Cocos2dxHelper"; static EditTextCallback s_editTextCallback = nullptr; static void* s_ctx = nullptr; -static int __deviceSampleRate = 44100; -static int __deviceAudioBufferSizeInFrames = 192; - static std::string g_apkPath; using namespace cocos2d; @@ -61,18 +58,6 @@ JNIEXPORT void JNICALL Java_org_cocos2dx_lib_Cocos2dxHelper_nativeSetContext(JNI FileUtilsAndroid::setassetmanager(AAssetManager_fromJava(env, assetManager)); } -JNIEXPORT void JNICALL Java_org_cocos2dx_lib_Cocos2dxHelper_nativeSetAudioDeviceInfo(JNIEnv*, - jclass, - jboolean isSupportLowLatency, - jint deviceSampleRate, - jint deviceAudioBufferSizeInFrames) -{ - __deviceSampleRate = deviceSampleRate; - __deviceAudioBufferSizeInFrames = deviceAudioBufferSizeInFrames; - LOGD("nativeSetAudioDeviceInfo: sampleRate: %d, bufferSizeInFrames: %d", __deviceSampleRate, - __deviceAudioBufferSizeInFrames); -} - JNIEXPORT void JNICALL Java_org_cocos2dx_lib_Cocos2dxHelper_nativeSetEditTextDialogResult(JNIEnv* env, jclass, jbyteArray text) @@ -166,16 +151,6 @@ int getObbAssetFileDescriptorJNI(const char* path, int64_t* startOffset, int64_t return fd; } -int getDeviceSampleRate() -{ - return __deviceSampleRate; -} - -int getDeviceAudioBufferSizeInFrames() -{ - return __deviceAudioBufferSizeInFrames; -} - void conversionEncodingJNI(const char* src, int byteSize, const char* fromCharset, char* dst, const char* newCharset) { JniMethodInfo methodInfo; diff --git a/core/platform/android/jni/Java_org_cocos2dx_lib_Cocos2dxHelper.h b/core/platform/android/jni/Java_org_cocos2dx_lib_Cocos2dxHelper.h index 417ecc746a..bfb342025c 100644 --- a/core/platform/android/jni/Java_org_cocos2dx_lib_Cocos2dxHelper.h +++ b/core/platform/android/jni/Java_org_cocos2dx_lib_Cocos2dxHelper.h @@ -38,8 +38,4 @@ extern void conversionEncodingJNI(const char* src, const char* fromCharset, char* dst, const char* newCharset); - -extern int getDeviceSampleRate(); -extern int getDeviceAudioBufferSizeInFrames(); - #endif /* __Java_org_cocos2dx_lib_Cocos2dxHelper_H__ */