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

Commit 2bd24505 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "libgui: fix a race in BufferQueueProducer::allocateBuffers"

parents 7a7d7e75 1dbf0e3b
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -1331,6 +1331,7 @@ void BufferQueueProducer::allocateBuffers(uint32_t width, uint32_t height,
        uint32_t allocHeight = 0;
        PixelFormat allocFormat = PIXEL_FORMAT_UNKNOWN;
        uint64_t allocUsage = 0;
        std::string allocName;
        { // Autolock scope
            Mutex::Autolock lock(mCore->mMutex);
            mCore->waitWhileAllocatingLocked();
@@ -1350,6 +1351,7 @@ void BufferQueueProducer::allocateBuffers(uint32_t width, uint32_t height,
            allocHeight = height > 0 ? height : mCore->mDefaultHeight;
            allocFormat = format != 0 ? format : mCore->mDefaultBufferFormat;
            allocUsage = usage | mCore->mConsumerUsageBits;
            allocName.assign(mCore->mConsumerName.string(), mCore->mConsumerName.size());

            mCore->mIsAllocating = true;
        } // Autolock scope
@@ -1358,7 +1360,7 @@ void BufferQueueProducer::allocateBuffers(uint32_t width, uint32_t height,
        for (size_t i = 0; i <  newBufferCount; ++i) {
            sp<GraphicBuffer> graphicBuffer = new GraphicBuffer(
                    allocWidth, allocHeight, allocFormat, BQ_LAYER_COUNT,
                    allocUsage, {mConsumerName.string(), mConsumerName.size()});
                    allocUsage, allocName);

            status_t result = graphicBuffer->initCheck();