Delete unused code

This commit is contained in:
halx99 2022-04-05 13:58:55 +08:00
parent 93f549a0ad
commit 893134c79d
3 changed files with 1 additions and 60 deletions

View File

@ -122,37 +122,7 @@ public class Cocos2dxHelper {
PackageManager pm = activity.getPackageManager(); PackageManager pm = activity.getPackageManager();
boolean isSupportLowLatency = pm.hasSystemFeature(PackageManager.FEATURE_AUDIO_LOW_LATENCY); boolean isSupportLowLatency = pm.hasSystemFeature(PackageManager.FEATURE_AUDIO_LOW_LATENCY);
Log.d(TAG, String.format("android version is %d, isSupportLowLatency: %s", Build.VERSION.SDK_INT, isSupportLowLatency ? "true" : "false") );
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.<String>getConstantValue(audioManagerClass, "PROPERTY_OUTPUT_SAMPLE_RATE")};
final String strSampleRate = Cocos2dxReflectionHelper.<String>invokeInstanceMethod(am, "getProperty", new Class[]{String.class}, parameters);
// AudioManager.getProperty(AudioManager.PROPERTY_OUTPUT_FRAMES_PER_BUFFER);
parameters = new Object[]{Cocos2dxReflectionHelper.<String>getConstantValue(audioManagerClass, "PROPERTY_OUTPUT_FRAMES_PER_BUFFER")};
final String strBufferSizeInFrames = Cocos2dxReflectionHelper.<String>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);
final ApplicationInfo applicationInfo = activity.getApplicationInfo(); final ApplicationInfo applicationInfo = activity.getApplicationInfo();

View File

@ -42,9 +42,6 @@ static const char* className = "org.cocos2dx.lib.Cocos2dxHelper";
static EditTextCallback s_editTextCallback = nullptr; static EditTextCallback s_editTextCallback = nullptr;
static void* s_ctx = nullptr; static void* s_ctx = nullptr;
static int __deviceSampleRate = 44100;
static int __deviceAudioBufferSizeInFrames = 192;
static std::string g_apkPath; static std::string g_apkPath;
using namespace cocos2d; using namespace cocos2d;
@ -61,18 +58,6 @@ JNIEXPORT void JNICALL Java_org_cocos2dx_lib_Cocos2dxHelper_nativeSetContext(JNI
FileUtilsAndroid::setassetmanager(AAssetManager_fromJava(env, assetManager)); 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, JNIEXPORT void JNICALL Java_org_cocos2dx_lib_Cocos2dxHelper_nativeSetEditTextDialogResult(JNIEnv* env,
jclass, jclass,
jbyteArray text) jbyteArray text)
@ -166,16 +151,6 @@ int getObbAssetFileDescriptorJNI(const char* path, int64_t* startOffset, int64_t
return fd; 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) void conversionEncodingJNI(const char* src, int byteSize, const char* fromCharset, char* dst, const char* newCharset)
{ {
JniMethodInfo methodInfo; JniMethodInfo methodInfo;

View File

@ -38,8 +38,4 @@ extern void conversionEncodingJNI(const char* src,
const char* fromCharset, const char* fromCharset,
char* dst, char* dst,
const char* newCharset); const char* newCharset);
extern int getDeviceSampleRate();
extern int getDeviceAudioBufferSizeInFrames();
#endif /* __Java_org_cocos2dx_lib_Cocos2dxHelper_H__ */ #endif /* __Java_org_cocos2dx_lib_Cocos2dxHelper_H__ */