首页 > 代码库 > android 拍照时强制开两个CPU
android 拍照时强制开两个CPU
进入相机拍照,拍照动画和拍照声音会概率性发生卡顿。
此问题发生的原因是在拍照期间概率性只有一颗CPU打开,而拍照时loading会比较重,导致一颗CPU处理不过来,所以会出现拍照动画和拍照声音卡顿的问题。
解决方法:拍照时强制开两颗CPU,足以处理拍照时的loading。
KK版本上可以按以下方法修改。
在photoactor.java中
1. 添加如下代码
import com.mediatek.common.MediatekClassFactory;
import com.mediatek.common.perfservice.IPerfServiceWrapper;
2. 添加如下变量
IPerfServiceWrapper mPerfService = null;
int mPerfServiceHandle = -1;
3. public PhotoActor(Camera context)中做如下修改
if (mWfdManager != null) {
mWfdManager.addListener(mWfdListener);
}
//add start
mPerfService = MediatekClassFactory.createInstance(IPerfServiceWrapper.class, context);
Log.d(TAG, "mPerfService =" + mPerfService);
if(mPerfService != null && mPerfServiceHandle == -1)
mPerfServiceHandle = mPerfService.userReg(2, 0);
//add end
mCameraSound = new MediaActionSound();
4. public boolean capture()中做如下修改
if (mContinuousShotPerformed) {
mStreamID = 0;
}
//add start
if(mPerfServiceHandle != -1 && mPerfService != null)
{
Log.d(TAG, "mPerfService.userEnableTimeout");
mPerfService.userEnableTimeout(mPerfServiceHandle, 10);
}
Log.d(TAG, "mPerfServiceHandle = " + mPerfServiceHandle);
//add end
synchronized (sFaceDetectionSync) {
if (!mCameraCategory.applySpecialCapture()) {
mContext.getCameraDevice().takePicture(getShutterCallback(), mRawPictureCallback,
mPostViewPictureCallback, mCameraCategory.getJpegPictureCallback());
}
sFaceDetectionStarted = false;
}
此问题发生的原因是在拍照期间概率性只有一颗CPU打开,而拍照时loading会比较重,导致一颗CPU处理不过来,所以会出现拍照动画和拍照声音卡顿的问题。
解决方法:拍照时强制开两颗CPU,足以处理拍照时的loading。
KK版本上可以按以下方法修改。
在photoactor.java中
1. 添加如下代码
import com.mediatek.common.MediatekClassFactory;
import com.mediatek.common.perfservice.IPerfServiceWrapper;
2. 添加如下变量
IPerfServiceWrapper mPerfService = null;
int mPerfServiceHandle = -1;
3. public PhotoActor(Camera context)中做如下修改
if (mWfdManager != null) {
mWfdManager.addListener(mWfdListener);
}
//add start
mPerfService = MediatekClassFactory.createInstance(IPerfServiceWrapper.class, context);
Log.d(TAG, "mPerfService =" + mPerfService);
if(mPerfService != null && mPerfServiceHandle == -1)
mPerfServiceHandle = mPerfService.userReg(2, 0);
//add end
mCameraSound = new MediaActionSound();
4. public boolean capture()中做如下修改
if (mContinuousShotPerformed) {
mStreamID = 0;
}
//add start
if(mPerfServiceHandle != -1 && mPerfService != null)
{
Log.d(TAG, "mPerfService.userEnableTimeout");
mPerfService.userEnableTimeout(mPerfServiceHandle, 10);
}
Log.d(TAG, "mPerfServiceHandle = " + mPerfServiceHandle);
//add end
synchronized (sFaceDetectionSync) {
if (!mCameraCategory.applySpecialCapture()) {
mContext.getCameraDevice().takePicture(getShutterCallback(), mRawPictureCallback,
mPostViewPictureCallback, mCameraCategory.getJpegPictureCallback());
}
sFaceDetectionStarted = false;
}
android 拍照时强制开两个CPU
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。