the camera api use open() , release() calls prevent multiple accesses different apps/processes, kind of want know how underlying mechanism works. example, there mutex share across different processes? can point me right place, did google search can't locate source code.
i linked kitkat source, since it's last version before android.hardware.camera2
introduced.
the lock tried this:
remote()->transact(lock, data, &reply);
where remote()
seems system service. refer answer remote: implementation of remote()
android source code
public native final void lock();
static void android_hardware_camera_lock(jnienv *env, jobject thiz) { alogv("lock"); sp<camera> camera = get_native_camera(env, thiz, null); if (camera == 0) return; if (camera->lock() != no_error) { jnithrowruntimeexception(env, "lock failed"); } }
https://android.googlesource.com/platform/frameworks/av/+/android-4.4.4_r2.0.1/camera/camera.cpp:
status_t camera::lock() { sp <icamera> c = mcamera; if (c == 0) return no_init; return c->lock(); }
class icamera: public iinterface { // prevent other processes using icamera interface virtual status_t lock() = 0; }
https://android.googlesource.com/platform/frameworks/av/+/android-4.4.4_r2.0.1/camera/icamera.cpp:
class bpcamera: public bpinterface<icamera> { virtual status_t lock() { parcel data, reply; data.writeinterfacetoken(icamera::getinterfacedescriptor()); remote()->transact(lock, data, &reply); return reply.readint32(); } }
Comments
Post a Comment