mirror of
https://github.com/team-infusion-developers/android_device_samsung_msm8976-common.git
synced 2024-11-07 06:19:20 +00:00
msm8976-common: Increase camera open retries
Cameras can be opened only after the camera server has configured them. Since Android N the framework usually tries to access the cameras to determine whether they have a flashlight too early, causing the flashlight tile not to work. Try to open the camera a few times before giving up to prevent this. Note that mm-qcamera-daemon already tries to open the camera twice with 20ms of delay, so the total number of attempts is two times the one defined here. Change-Id: I664fdfdafe0829719fcd0a6a31057d761e4f07d9
This commit is contained in:
parent
ffe2d49318
commit
fa96152a8c
1 changed files with 13 additions and 3 deletions
|
@ -33,6 +33,9 @@
|
|||
#include <camera/Camera.h>
|
||||
#include <camera/CameraParameters.h>
|
||||
|
||||
#define OPEN_RETRIES 10
|
||||
#define OPEN_RETRY_MSEC 40
|
||||
|
||||
using namespace android;
|
||||
|
||||
static Mutex gCameraWrapperLock;
|
||||
|
@ -516,9 +519,16 @@ static int camera_device_open(const hw_module_t *module, const char *name,
|
|||
memset(camera_device, 0, sizeof(*camera_device));
|
||||
camera_device->id = cameraid;
|
||||
|
||||
rv = gVendorModule->common.methods->open(
|
||||
(const hw_module_t*)gVendorModule, name,
|
||||
(hw_device_t**)&(camera_device->vendor));
|
||||
int retries = OPEN_RETRIES;
|
||||
bool retry;
|
||||
do {
|
||||
rv = gVendorModule->common.methods->open(
|
||||
(const hw_module_t*)gVendorModule, name,
|
||||
(hw_device_t**)&(camera_device->vendor));
|
||||
retry = --retries > 0 && rv;
|
||||
if (retry)
|
||||
usleep(OPEN_RETRY_MSEC * 1000);
|
||||
} while (retry);
|
||||
if (rv) {
|
||||
ALOGE("vendor camera open fail");
|
||||
goto fail;
|
||||
|
|
Loading…
Reference in a new issue