diff --git a/native/cocos/base/base64.cpp b/native/cocos/base/base64.cpp index 668eec7fec..3172607c0e 100644 --- a/native/cocos/base/base64.cpp +++ b/native/cocos/base/base64.cpp @@ -142,15 +142,12 @@ int base64Decode(const unsigned char *in, unsigned int inLength, unsigned char * unsigned int outLength = 0; //should be enough to store 6-bit buffers in 8-bit buffers - *out = (unsigned char*)malloc(inLength * 3.0f / 4.0f + 1); + *out = (unsigned char*)malloc(inLength / 4 * 3 + 1); if( *out ) { int ret = _base64Decode(in, inLength, *out, &outLength); - if (ret > 0 ) + if (ret > 0) { -#if (CC_TARGET_PLATFORM != CC_PLATFORM_BADA) - printf("Base64Utils: error decoding"); -#endif free(*out); *out = nullptr; outLength = 0; @@ -160,7 +157,7 @@ int base64Decode(const unsigned char *in, unsigned int inLength, unsigned char * } int base64Encode(const unsigned char *in, unsigned int inLength, char **out) { - unsigned int outLength = inLength * 4 / 3 + (inLength % 3 > 0 ? 4 : 0); + unsigned int outLength = (inLength + 2) / 3 * 4; //should be enough to store 8-bit buffers in 6-bit buffers *out = (char*)malloc(outLength+1); diff --git a/native/cocos/platform/android/java/src/org/cocos2dx/lib/Cocos2dxActivity.java b/native/cocos/platform/android/java/src/org/cocos2dx/lib/Cocos2dxActivity.java index 03f746b7b8..074b90b23a 100644 --- a/native/cocos/platform/android/java/src/org/cocos2dx/lib/Cocos2dxActivity.java +++ b/native/cocos/platform/android/java/src/org/cocos2dx/lib/Cocos2dxActivity.java @@ -30,6 +30,7 @@ import android.content.Intent; import android.content.pm.ApplicationInfo; import android.content.pm.PackageManager; import android.graphics.PixelFormat; +import android.media.AudioManager; import android.opengl.GLSurfaceView; import android.os.Build; import android.os.Bundle; @@ -266,6 +267,7 @@ public abstract class Cocos2dxActivity extends Activity { Cocos2dxWebViewHelper.init(); Window window = getWindow(); window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN); + this.setVolumeControlStream(AudioManager.STREAM_MUSIC); } //native method,call GLViewImpl::getGLContextAttrs() to get the OpenGL ES context attributions