cocos2dx i9100 上播放音频bug

我的版本是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);

你可能感兴趣的:(cocos2dx i9100 上播放音频bug)