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

Commit 1e06f435 authored by Sundar Raman's avatar Sundar Raman Committed by Iliyan Malchev
Browse files

CameraService: Decouple dequeue and lock



Decouple lockBuffer from dequeueBuffer. Add lock_buffer to preview_stream_ops,
so HALs will be fully in charge of managing buffers.

Change-Id: I7b53487d618bdf08ba904c5a0f41af462a7ca773
Signed-off-by: default avatarIliyan Malchev <malchev@google.com>
parent 34bac592
Loading
Loading
Loading
Loading
+11 −7
Original line number Original line Diff line number Diff line
@@ -558,15 +558,10 @@ private:
        ANativeWindow *a = anw(w);
        ANativeWindow *a = anw(w);
        ANativeWindowBuffer* anb;
        ANativeWindowBuffer* anb;
        rc = a->dequeueBuffer(a, &anb);
        rc = a->dequeueBuffer(a, &anb);
        if (!rc) {
            rc = a->lockBuffer(a, anb);
        if (!rc) {
        if (!rc) {
            *buffer = &anb->handle;
            *buffer = &anb->handle;
            *stride = anb->stride;
            *stride = anb->stride;
        }
        }
            else
                a->cancelBuffer(a, anb);
        }
        return rc;
        return rc;
    }
    }


@@ -576,6 +571,14 @@ private:
        (type *) ((char *) __mptr - (char *)(&((type *)0)->member)); })
        (type *) ((char *) __mptr - (char *)(&((type *)0)->member)); })
#endif
#endif


    static int __lock_buffer(struct preview_stream_ops* w,
                      buffer_handle_t* buffer)
    {
        ANativeWindow *a = anw(w);
        return a->lockBuffer(a,
                  container_of(buffer, ANativeWindowBuffer, handle));
    }

    static int __enqueue_buffer(struct preview_stream_ops* w,
    static int __enqueue_buffer(struct preview_stream_ops* w,
                      buffer_handle_t* buffer)
                      buffer_handle_t* buffer)
    {
    {
@@ -641,6 +644,7 @@ private:
    void initHalPreviewWindow()
    void initHalPreviewWindow()
    {
    {
        mHalPreviewWindow.nw.cancel_buffer = __cancel_buffer;
        mHalPreviewWindow.nw.cancel_buffer = __cancel_buffer;
        mHalPreviewWindow.nw.lock_buffer = __lock_buffer;
        mHalPreviewWindow.nw.dequeue_buffer = __dequeue_buffer;
        mHalPreviewWindow.nw.dequeue_buffer = __dequeue_buffer;
        mHalPreviewWindow.nw.enqueue_buffer = __enqueue_buffer;
        mHalPreviewWindow.nw.enqueue_buffer = __enqueue_buffer;
        mHalPreviewWindow.nw.set_buffer_count = __set_buffer_count;
        mHalPreviewWindow.nw.set_buffer_count = __set_buffer_count;