Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > Capturing and Editing Video > Avisynth Development

Reply
 
Thread Tools Search this Thread Display Modes
Old 31st May 2021, 13:47   #1  |  Link
wonkey_monkey
Formerly davidh*****
 
wonkey_monkey's Avatar
 
Join Date: Jan 2004
Posts: 2,493
Sharing a variable between all instances of a plugin, per environment

I'm writing a plugin where all instances need to access one instance of a variable (a vector). I can declare it as static and this works fine.

But the problem arises that the variable is shared even across different IScriptEnvironments, so that if my process tries to create a new IScriptEnvironment (which it does when reloading an .avs file, to check that it's valid before deleting the old environment), any instances of the plugin in the new script environment can still see the data in the vector from the old instance.

One thought that occurs to me is to add a new function to the plugin which serves only to store, and return a pointer to, the vector. This would (if I understand correctly) have to be disguised as an AVSValue, and for x64 it would to be a 64-bit value. I think that means it would have to be cast to either a PClip - which could causes problems as it wouldn't be a real smart pointer to a clip? - or I see there's also a .AsDblDef member of AVSValue. But I thought I'd heard pinterf say recently that there weren't any 64-bit AVSValues...

EDIT: Scrap that. The new function would have to have the vector as a static variable just the same as before, and would therefore run into the same problem.

Is there any way of doing this? Can I tack my variable's pointer onto the environment somewhere?

Edit: I could keep track of the env pointer, and separate the entries in the vector that way, but that sounds dodgy. Not that I expect the vector to get very big, but it would be a leak because I don't think I'd have any way of knowing that a particular environment had been destroyed. Plus the other instances wouldn't be able to update their indices if the entries in the vector were deleted.
__________________
My AviSynth filters / I'm the Doctor

Last edited by wonkey_monkey; 31st May 2021 at 13:59.
wonkey_monkey is offline   Reply With Quote
Old 31st May 2021, 21:09   #2  |  Link
Myrsloik
Professional Code Monkey
 
Myrsloik's Avatar
 
Join Date: Jun 2003
Location: Kinnarps Chair
Posts: 2,548
What information are you storing that's shared between all plugin instances in one environment but can't be globally shared?

You should really describe the whole problem if you want a good solution.
__________________
VapourSynth - proving that scripting languages and video processing isn't dead yet
Myrsloik is offline   Reply With Quote
Old 31st May 2021, 23:01   #3  |  Link
wonkey_monkey
Formerly davidh*****
 
wonkey_monkey's Avatar
 
Join Date: Jan 2004
Posts: 2,493
It's a vector of clip pointers with an associated integer ID. I went with storing the env pointer along with each clip so that environments can be kept separate.

https://forum.doom9.org/showthread.php?t=182910
__________________
My AviSynth filters / I'm the Doctor
wonkey_monkey is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 00:12.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.