Fix a media server crash (bug 1807910): part one
Add a factory method that creates a Camera object from a remote client
Next:
The changes in authordriver.cpp and android_camera_input.cpp will come.
and the constructor for Camera object will be removed.
diff --git a/libs/ui/Camera.cpp b/libs/ui/Camera.cpp
index b3cbda1..0fba82c 100644
--- a/libs/ui/Camera.cpp
+++ b/libs/ui/Camera.cpp
@@ -75,6 +75,19 @@
}
}
+
+sp<Camera> Camera::create(const sp<ICamera>& camera)
+{
+ sp<Camera> c = new Camera();
+ // connect this client to existing camera remote
+ if (camera->connect(c) == NO_ERROR) {
+ c->mStatus = NO_ERROR;
+ c->mCamera = camera;
+ camera->asBinder()->linkToDeath(c);
+ }
+ return c;
+}
+
void Camera::init()
{
mStatus = UNKNOWN_ERROR;