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

Commit 53333c11 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Use refcounts to manage lifetime of AChoreographer*." into main

parents 8aff163b 61fbbc52
Loading
Loading
Loading
Loading
+7 −3
Original line number Diff line number Diff line
@@ -238,13 +238,17 @@ int64_t AChoreographerFrameCallbackData_getFrameTimelineDeadlineNanos(
}

AChoreographer* AChoreographer_create() {
    Choreographer* choreographer = new Choreographer(nullptr);
    // Increments default strongRef count on construction, will be decremented on
    // function exit.
    auto choreographer = sp<Choreographer>::make(nullptr);
    status_t result = choreographer->initialize();
    if (result != OK) {
        ALOGW("Failed to initialize");
        return nullptr;
    }
    return Choreographer_to_AChoreographer(choreographer);
    // Will be decremented and destroyed by AChoreographer_destroy
    choreographer->incStrong((void*)AChoreographer_create);
    return Choreographer_to_AChoreographer(choreographer.get());
}

void AChoreographer_destroy(AChoreographer* choreographer) {
@@ -252,7 +256,7 @@ void AChoreographer_destroy(AChoreographer* choreographer) {
        return;
    }

    delete AChoreographer_to_Choreographer(choreographer);
    AChoreographer_to_Choreographer(choreographer)->decStrong((void*)AChoreographer_create);
}

int AChoreographer_getFd(const AChoreographer* choreographer) {