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

Commit afabf7b6 authored by Anton Ivanov's avatar Anton Ivanov
Browse files

Harden construction sites of android::Surface.

Since this type is inteded to be managed as a StrongPointer, ensure that
is always constructed as such.

Bug: 393217449
Test: presubmit
Flag: EXEMPT_refactor
Change-Id: Ibbef08ac65feb5508b87ee36269a99d55eb050b7
parent 90574aa0
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -118,7 +118,7 @@ status_t CaptureRequest::readFromParcel(const android::Parcel* parcel) {
#else
        sp<Surface> surface;
        if (surfaceShim.graphicBufferProducer != NULL) {
            surface = new Surface(surfaceShim.graphicBufferProducer);
            surface = sp<Surface>::make(surfaceShim.graphicBufferProducer);
        }
#endif
        mSurfaceList.push_back(surface);
+1 −1
Original line number Diff line number Diff line
@@ -142,7 +142,7 @@ status_t FrameCaptureLayer::init() {
    }

    mConsumer = consumer;
    mSurface = new Surface(producer);
    mSurface = sp<Surface>::make(producer);

    return OK;
}
+1 −1
Original line number Diff line number Diff line
@@ -762,7 +762,7 @@ class MediaCodec::ReleaseSurface {
public:
    explicit ReleaseSurface(uint64_t usage) {
        BufferQueue::createBufferQueue(&mProducer, &mConsumer);
        mSurface = new Surface(mProducer, false /* controlledByApp */);
        mSurface = sp<Surface>::make(mProducer, false /* controlledByApp */);
        struct ConsumerListener : public IConsumerListener {
            ConsumerListener(const sp<IGraphicBufferConsumer> &consumer) {
                mConsumer = consumer;
+6 −1
Original line number Diff line number Diff line
@@ -824,7 +824,12 @@ media_status_t AMediaCodec_createInputSurface(AMediaCodec *mData, ANativeWindow
        return translate_error(err);
    }

    *surface = new Surface(igbp);
    // This will increment default strongCount on construction.  It will be decremented
    // on function exit.
    auto spSurface = sp<Surface>::make(igbp);
    *surface = spSurface.get();
    // This will increment a private strongCount.  It will be decremented in
    // ANativeWindow_release.
    ANativeWindow_acquire(*surface);
    return AMEDIA_OK;
}