File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -238,21 +238,25 @@ int64_t AChoreographerFrameCallbackData_getFrameTimelineDeadlineNanos(
238238}
239239
240240AChoreographer* AChoreographer_create () {
241- Choreographer* choreographer = new Choreographer (nullptr );
241+ // Increments default strongRef count on construction, will be decremented on
242+ // function exit.
243+ auto choreographer = sp<Choreographer>::make (nullptr );
242244 status_t result = choreographer->initialize ();
243245 if (result != OK) {
244246 ALOGW (" Failed to initialize" );
245247 return nullptr ;
246248 }
247- return Choreographer_to_AChoreographer (choreographer);
249+ // Will be decremented and destroyed by AChoreographer_destroy
250+ choreographer->incStrong ((void *)AChoreographer_create);
251+ return Choreographer_to_AChoreographer (choreographer.get ());
248252}
249253
250254void AChoreographer_destroy (AChoreographer* choreographer) {
251255 if (choreographer == nullptr ) {
252256 return ;
253257 }
254258
255- delete AChoreographer_to_Choreographer (choreographer);
259+ AChoreographer_to_Choreographer (choreographer)-> decStrong (( void *)AChoreographer_create );
256260}
257261
258262int AChoreographer_getFd (const AChoreographer* choreographer) {
You can’t perform that action at this time.
0 commit comments