synchronize access to camera, etc to avoid race condition