Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

SmartFX, Is there any harm in checking in params immediately after checking them out

Engaged ,
Oct 21, 2021 Oct 21, 2021

In smartFX I have gotten into the habit of checking in/out params in this fashion because it's incredibly convenient and scales based on the number of parameters:

 

PF_ParamDef params[NUM_PARAMS]; AEFX_CLR_STRUCT(params);

for(int i = 1; i < NUM_PARAMS; i++)
{
    ERR(PF_CHECKOUT_PARAM(in_data, i, in_data->current_time, in_data->time_step, in_data->time_scale, &params[i]));
    ERR2(PF_CHECKIN_PARAM(in_data, &params[i]));
}

 

 

The advantages of this:

  • Can safely return from the function at any point, don't have to worry about manual garbage collection which becomes annoying if you have multiple possible return cases
  • Less memory usage (params are checked in as soon as they are checked out, though this would be minimal). No extra overhead if all params actually needed to be checked out.

 

Disadvantages of this:

  • If you accidentally check out param[0] this way, even checking it back in gives memory leaks
  • Again if you checkout param[0] and immediately check it back in, and try to purge all multiple times AE will crash. So there's obviously something about doing that which is very bad practice. I know that you should access layer pixels with the checkout_layer_pixels, but even in smartFX, the input layer without any previous effects applied is still accessible through checking out a param def. 
  • None others that I can see, but I may be mistaken!
TOPICS
SDK
158
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 21, 2021 Oct 21, 2021

plain old data (such as slider value) survives this method as it's copied to your local array. however, data that is fetched or has some temp instance of it made such as layer pixel buffers or arb param handle becomes invalid after checking in. you might get lucky an have AE still not re-use the same bit of memory until after you've finished, but you can't rely on it.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Oct 21, 2021 Oct 21, 2021
LATEST

Thanks Shachar, good to know never to use it on arb params or layer pixels. 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines