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

Commit 9e9aae44 authored by Aurimas Liutikas's avatar Aurimas Liutikas Committed by Android (Google) Code Review
Browse files

Merge "SF: Add a lock guard to mLayerHistory"

parents 74fe9547 6da0e492
Loading
Loading
Loading
Loading
+20 −16
Original line number Diff line number Diff line
@@ -299,6 +299,7 @@ void Scheduler::addFramePresentTimeForLayer(const nsecs_t framePresentTime, bool
}

void Scheduler::incrementFrameCounter() {
    std::lock_guard<std::mutex> lock(mLayerHistoryLock);
    mLayerHistory.incrementCounter();
}

@@ -323,12 +324,14 @@ void Scheduler::updateFrameSkipping(const int64_t skipCount) {

void Scheduler::determineLayerTimestampStats(const std::string layerName,
                                             const nsecs_t framePresentTime) {
    mLayerHistory.insert(layerName, framePresentTime);
    std::vector<int64_t> differencesMs;
    std::string differencesText = "";
    {
        std::lock_guard<std::mutex> lock(mLayerHistoryLock);
        mLayerHistory.insert(layerName, framePresentTime);

        // Traverse through the layer history, and determine the differences in present times.
        nsecs_t newestPresentTime = framePresentTime;
    std::string differencesText = "";
        for (int i = 1; i < mLayerHistory.getSize(); i++) {
            std::unordered_map<std::string, nsecs_t> layers = mLayerHistory.get(i);
            for (auto layer : layers) {
@@ -344,6 +347,7 @@ void Scheduler::determineLayerTimestampStats(const std::string layerName,
                newestPresentTime = layer.second;
            }
        }
    }
    ALOGV("Layer %s timestamp intervals: %s", layerName.c_str(), differencesText.c_str());

    if (!differencesMs.empty()) {
+4 −1
Original line number Diff line number Diff line
@@ -201,7 +201,10 @@ private:
    std::array<int64_t, scheduler::ARRAY_SIZE> mTimeDifferences{};
    size_t mCounter = 0;

    LayerHistory mLayerHistory;
    // DetermineLayerTimestampStats is called from BufferQueueLayer::onFrameAvailable which
    // can run on any thread, and cause failure.
    std::mutex mLayerHistoryLock;
    LayerHistory mLayerHistory GUARDED_BY(mLayerHistoryLock);

    // Timer that records time between requests for next vsync. If the time is higher than a given
    // interval, a callback is fired. Set this variable to >0 to use this feature.