Skip to main content
Inspiring
September 17, 2024
Question

sequence_data life cycle

  • September 17, 2024
  • 2 replies
  • 352 views

Hello,

 

I am creating an object instance during PF_Cmd_SEQUENCE_SETUP and I want to use reference counting to keep it around during PF_Cmd_SEQUENCE_FLATTEN, PF_Cmd_SEQUENCE_RESETUP and 

PF_Cmd_SEQUENCE_SETDOWN.

 

What I do:

  • Setup: creates the object instance and associates an UUID to it and sequence_data stores object instance pointer + UUID.
  • Flatten: creates a flat representation of sequence_data (used for serialization). In my case, I put the UUID of my object in the flat data.
  • Resetup: get back a pointer to the object from UUID or create one if not found (when loading from a file)
  • Setdown: release the object if ref count goes down to 0.

 

I am not sure how to do ref counting. For example, if I create a new project with a media, associate the plugin to a layer and then close the project, I got these numbers of call (in AE 2024 24.6.1 build 2):

- Setup: 1

- Flatten: 1

- Resetup: 4

- Setdown: 4

 

This works for sequence_data which is created in Setup, destroyed in Flatten (which creates a flat sequence_data which is kept around), sequence_data (unflat) is then recreated in Resetup. So Setdown is OK to destroy the 4 sequence_data creatd in Resetup.

 

In my case, I do not want to release my object instance in Flatten. So perhaps, I should release it when ref count goes down to one in Setdown or use PF_Cmd_GET_FLATTENED_SEQUENCE_DATA ?

This topic has been closed for replies.

2 replies

r2d3_Author
Inspiring
September 17, 2024

So I tested using PF_Cmd_GET_FLATTENED_SEQUENCE_DATA and I get:

  • Setup: 1
  • GetFlattened: 1
  • Resetup: 5
  • Setdown: 6

 

In this config, I object instance could survive the flatten and could be released when ref count is 0

Community Expert
September 17, 2024

i think the PF_Cmd_GET_FLATTENED_SEQUENCE_DATA applies only to render threads and not the UI thread. play with it some more with previews and project open/close undo/redo/copy/paste/duplicate ect.

for example, duplicate behaves differently than copy/paste.

r2d3_Author
Inspiring
September 17, 2024

You are right, PF_Cmd_SEQUENCE_FLATTEN is called in some cases.

Community Expert
September 17, 2024

well... it's complicated...

when saving the project while quitting, you might get a flatten call without getting a setdown call after it. in that case, you can of course free all derelict handles on global_setdown, so no biggie.

it's a there's no robust instance identificaiton method, but that's what we have.