cocos2dx i9100 上播放音频bug

来源:互联网 发布:人工智能议论文800字 编辑:程序博客网 时间:2024/06/07 18:44

我的版本是2.0.3

1. in file "CocosDenshion/android/opensl/OpenSLEngine.cpp", line 21
#define CLASS_NAME "org/cocos2dx/lib/Cocos2dxActivity"
must change to
#define CLASS_NAME "org/cocos2dx/lib/Cocos2dxHelper"

the java method "getAssetManager" is moved from Cocos2dxActivity.java to Cocos2dxActivity.java, but didn't change the jni file.

2. in file "CocosDenshion/android/SimpleAudioEngine.cpp", line 157

const char* deviceModel = methodInfo.env->GetStringUTFChars(jstr, NULL);    methodInfo.env->ReleaseStringUTFChars(jstr, deviceModel);    methodInfo.env->DeleteLocalRef(jstr);    LOGD(deviceModel);    if (strcmp(I9100_MODEL, deviceModel) == 0) {    LOGD("i9100 model\nSwitch to OpenSLES");    s_bI9100 = true;    }
will cause deviceModel release before compare with I9100_MODEL, sometime LOGD(deviceModel); will print garbled character in logcat. change to following code will fix it
const char* deviceModel = methodInfo.env->GetStringUTFChars(jstr, NULL);    LOGD(deviceModel);    if (strcmp(I9100_MODEL, deviceModel) == 0){    LOGD("i9100 model\nSwitch to OpenSLES");    s_bI9100 = true;    }    methodInfo.env->ReleaseStringUTFChars(jstr, deviceModel);    methodInfo.env->DeleteLocalRef(jstr);