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

Commit 547ecf42 authored by Eino-Ville Talvala's avatar Eino-Ville Talvala Committed by Android Git Automerger
Browse files

am 48e5df72: Merge "Camera: Add hidden experimental tearDown method." into mnc-dev

* commit '48e5df72':
  Camera: Add hidden experimental tearDown method.
parents 489aaa45 48e5df72
Loading
Loading
Loading
Loading
+23 −1
Original line number Diff line number Diff line
@@ -48,7 +48,8 @@ enum {
    GET_CAMERA_INFO,
    WAIT_UNTIL_IDLE,
    FLUSH,
    PREPARE
    PREPARE,
    TEAR_DOWN
};

namespace {
@@ -365,6 +366,20 @@ public:
        return reply.readInt32();
    }

    virtual status_t tearDown(int streamId)
    {
        ALOGV("tearDown");
        Parcel data, reply;

        data.writeInterfaceToken(ICameraDeviceUser::getInterfaceDescriptor());
        data.writeInt32(streamId);

        remote()->transact(TEAR_DOWN, data, &reply);

        reply.readExceptionCode();
        return reply.readInt32();
    }

private:


@@ -570,6 +585,13 @@ status_t BnCameraDeviceUser::onTransact(
            reply->writeInt32(prepare(streamId));
            return NO_ERROR;
        } break;
        case TEAR_DOWN: {
            CHECK_INTERFACE(ICameraDeviceUser, data, reply);
            int streamId = data.readInt32();
            reply->writeNoException();
            reply->writeInt32(tearDown(streamId));
            return NO_ERROR;
        } break;

        default:
            return BBinder::onTransact(code, data, reply, flags);
+6 −0
Original line number Diff line number Diff line
@@ -138,6 +138,12 @@ public:
     * Preallocate buffers for a given output stream asynchronously.
     */
    virtual status_t        prepare(int streamId) = 0;

    /**
     * Free all unused buffers for a given output stream.
     */
    virtual status_t        tearDown(int streamId) = 0;

};

// ----------------------------------------------------------------------------
+32 −0
Original line number Diff line number Diff line
@@ -719,6 +719,38 @@ status_t CameraDeviceClient::prepare(int streamId) {
    return res;
}

status_t CameraDeviceClient::tearDown(int streamId) {
    ATRACE_CALL();
    ALOGV("%s", __FUNCTION__);

    status_t res = OK;
    if ( (res = checkPid(__FUNCTION__) ) != OK) return res;

    Mutex::Autolock icl(mBinderSerializationLock);

    // Guard against trying to prepare non-created streams
    ssize_t index = NAME_NOT_FOUND;
    for (size_t i = 0; i < mStreamMap.size(); ++i) {
        if (streamId == mStreamMap.valueAt(i)) {
            index = i;
            break;
        }
    }

    if (index == NAME_NOT_FOUND) {
        ALOGW("%s: Camera %d: Invalid stream ID (%d) specified, no stream "
              "created yet", __FUNCTION__, mCameraId, streamId);
        return BAD_VALUE;
    }

    // Also returns BAD_VALUE if stream ID was not valid or if the stream is in
    // use
    res = mDevice->tearDown(streamId);

    return res;
}


status_t CameraDeviceClient::dump(int fd, const Vector<String16>& args) {
    String8 result;
    result.appendFormat("CameraDeviceClient[%d] (%p) dump:\n",
+3 −0
Original line number Diff line number Diff line
@@ -111,6 +111,9 @@ public:
    // Prepare stream by preallocating its buffers
    virtual status_t      prepare(int streamId);

    // Tear down stream resources by freeing its unused buffers
    virtual status_t      tearDown(int streamId);

    /**
     * Interface used by CameraService
     */
+5 −0
Original line number Diff line number Diff line
@@ -288,6 +288,11 @@ class CameraDeviceBase : public virtual RefBase {
     */
    virtual status_t prepare(int streamId) = 0;

    /**
     * Free stream resources by dumping its unused gralloc buffers.
     */
    virtual status_t tearDown(int streamId) = 0;

    /**
     * Get the HAL device version.
     */
Loading