Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 851a14eb authored by Iliyan Malchev's avatar Iliyan Malchev Committed by Android (Google) Code Review
Browse files

Merge "Add initialize method to CameraHardwareInterface"

parents d8b505d5 7b6da3c7
Loading
Loading
Loading
Loading
+19 −10
Original line number Diff line number Diff line
@@ -80,25 +80,34 @@ typedef void (*data_callback_timestamp)(nsecs_t timestamp,

class CameraHardwareInterface : public virtual RefBase {
public:
    CameraHardwareInterface(hw_module_t *module, const char *name)
    CameraHardwareInterface(const char *name)
    {
        mDevice = 0;
        mName = name;
        LOGI("Opening camera %s, this %p", name, this);
        int rc = module->methods->open(module, name,
                                       (hw_device_t **)&mDevice);
        if (rc != OK)
            LOGE("Could not open camera %s: %d", name, rc);
        initHalPreviewWindow();
    }

    ~CameraHardwareInterface()
    {
        LOGI("Destroying camera %s", mName.string());
        if(mDevice) {
            int rc = mDevice->common.close(&mDevice->common);
            if (rc != OK)
                LOGE("Could not close camera %s: %d", mName.string(), rc);
        }
    }

    status_t initialize(hw_module_t *module)
    {
        LOGI("Opening camera %s", mName.string());
        int rc = module->methods->open(module, mName.string(),
                                       (hw_device_t **)&mDevice);
        if (rc != OK) {
            LOGE("Could not open camera %s: %d", mName.string(), rc);
            return rc;
        }
        initHalPreviewWindow();
        return rc;
    }

    /** Set the ANativeWindow to which preview frames are sent */
    status_t setPreviewWindow(const sp<ANativeWindow>& buf)
+9 −4
Original line number Diff line number Diff line
@@ -133,6 +133,8 @@ status_t CameraService::getCameraInfo(int cameraId,
sp<ICamera> CameraService::connect(
        const sp<ICameraClient>& cameraClient, int cameraId) {
    int callingPid = getCallingPid();
    sp<CameraHardwareInterface> hardware = NULL;

    LOG1("CameraService::connect E (pid %d, id %d)", callingPid, cameraId);

    if (!mModule) {
@@ -187,10 +189,13 @@ sp<ICamera> CameraService::connect(
    char camera_device_name[10];
    snprintf(camera_device_name, sizeof(camera_device_name), "%d", cameraId);

    client = new Client(this, cameraClient,
                new CameraHardwareInterface(&mModule->common,
                                            camera_device_name),
                cameraId, info.facing, callingPid);
    hardware = new CameraHardwareInterface(camera_device_name);
    if (hardware->initialize(&mModule->common) != OK) {
        hardware.clear();
        return NULL;
    }

    client = new Client(this, cameraClient, hardware, cameraId, info.facing, callingPid);
    mClient[cameraId] = client;
    LOG1("CameraService::connect X");
    return client;