Quick Sign In:  

Forum: VirtualDJ Plugins

Topic: calling GetStringInfo from timer

This topic is old and might contain outdated or incorrect information.

k090PRO InfinityMember since 2006
Hi,
I've decided to write own generic plugin (based on MyPlugin8 example) and I have a problem. I would like to use timer with GetStringInfo, to read actual data fromVDJ.
I set up my timer in OnLoad:

CreateTimerQueueTimer(&g_hTimer, NULL, TimerCallback, param, interval, interval, 0)

Timer definition:

VOID CALLBACK TimerCallback(PVOID lpParameter, BOOLEAN reserved)
{
HRESULT hr = S_FALSE;
char mystr[100];
CMyPlugin8 getStr;
hr = getStr.GetStringInfo("get_vdj_folder",mystr , 100);
}


And the problem is that each timer's cycle restarts VDJ.
Do you have any idea how to read data by GetStringInfo using a timer or maybe how to generate event at every beat of played music?
 

Posted Tue 27 Dec 16 @ 6:47 pm
SBDJPRO Infinity Member since 2006
In your timer callback you are creating a new instance of your plugin; one not actually linked with VDJ (CMyPlugin8 getStr). You need to pass a pointer to your original plugin instance instead.

CreateTimerQueueTimer(&g_hTimer, NULL, TimerCallback, this, interval, interval, 0);

then in your callback:

VOID CALLBACK TimerCallback(PVOID lpParameter, BOOLEAN reserved)
{
HRESULT hr = S_FALSE;
char mystr[100];
hr = ((CMyPlugin8*)lpParameter)->GetStringInfo("get_vdj_folder",mystr , 100);
}

This way you are passing the current instance of your plugin (this) to the callback function as the parameter. Then you are casting the parameter and are then able to call GetStringInfo.

Puzzled as to why you would be needing to call 'get_vdj_folder' from a callback though? It doesn't change and is immediately available. I'm guessing it's just a test? :)

Personally I'd prefer using a thread rather than a timer queue.
 

Posted Tue 27 Dec 16 @ 7:50 pm
k090PRO InfinityMember since 2006
It works! Thanks a lot! :)
 

Posted Tue 27 Dec 16 @ 9:00 pm
Very interesting post. For example purposes, how might you use a thread to write any text to anywhere on the VDJ console screen every few seconds?

Found some info here something like this:

HRESULT VDJ_API CMyPlugin8::OnLoad()
{
started=true;

hThread=CreateThread(NULL, 0, &NewThread, (LPVOID)this,NULL, &dwThreadId);
if (hThread==NULL) MessageBox(NULL,"Error while creating the new Thread (Multi-Threading used)","Plug-in",MB_OK|MB_ICONERROR);

}

but where do I put :

bool started; // Control the activity of the thread: ON or OFF (global variable)
HANDLE hThread;
DWORD dwThreadId;

and how can I write to a part of the console some text like the time. (Maybe I should create another thread on this forum for that)
 

Posted Sat 04 Feb 17 @ 3:30 am
SBDJPRO Infinity Member since 2006
They are class variables, so put them in your class declaration.

Writing text is more complicated. If you want to display text in the actual VDJ skin, then the user would need to be using a custom skin to do so. You can easily write text to your plugin configuration screen though.
 

Posted Mon 06 Feb 17 @ 10:35 am


(Old topics and forums are automatically closed)