Strange ROT behavior question
-
Hi all, Currently I'm writing two plugins for Windows Media Player. One plugin is DSP processor and the other - Visualisation. I need my plugins can communicate with each other though COM interfaces. So I create my own moniker class to register one of the objects in ROT. When my DSP pluging object is constructed I create moniker in the FinalConstruct (constructor) and register my object in ROT with ROTFLAGS_REGISTRATIONKEEPSALIVE flag. Later when my vis plugin needs to communicate with DSP plugin it also create moniker and binds it to DSP plugin - all works ok. But I cannot understand WHY when Win MediaPlayer releases my DSP plugin the plugin is destructed ? I mean that ROT also releases the pointer to my DSP plugin. Actually that is what I really need, but from docs I would expect different behavior - I suppose that ROT holds "strong" (I wonder where the explanation this term) reference to my DSP plugin so it will remain in memory until Revoke ? Also when I remove ROTFLAGS_REGISTRATIONKEEPSALIVE flag in IRunningObjectTable::Register method call my moniker cannot bind to object. Short description on the object which being registered in ROT: HRESULT DSPPlug::FinalContruct() { CComPtr p = CreateMoniker(); ... CComPtr pIROT; ::GetRunningObjectTable(NULL,&pIROT); ... pIROT->Register(ROTFLAGS_REGISTRATIONKEEPSALIVE,this,p,&this->ROTRegValue); } void DSPPlug::FinalRelease() { CComPtr pIROT; ::GetRunningObjectTable(NULL,&pIROT); ... pIROT->Revoke(this->ROTRegValue); } Can someone help with explanation of those ? Best regards, Valery
-
Hi all, Currently I'm writing two plugins for Windows Media Player. One plugin is DSP processor and the other - Visualisation. I need my plugins can communicate with each other though COM interfaces. So I create my own moniker class to register one of the objects in ROT. When my DSP pluging object is constructed I create moniker in the FinalConstruct (constructor) and register my object in ROT with ROTFLAGS_REGISTRATIONKEEPSALIVE flag. Later when my vis plugin needs to communicate with DSP plugin it also create moniker and binds it to DSP plugin - all works ok. But I cannot understand WHY when Win MediaPlayer releases my DSP plugin the plugin is destructed ? I mean that ROT also releases the pointer to my DSP plugin. Actually that is what I really need, but from docs I would expect different behavior - I suppose that ROT holds "strong" (I wonder where the explanation this term) reference to my DSP plugin so it will remain in memory until Revoke ? Also when I remove ROTFLAGS_REGISTRATIONKEEPSALIVE flag in IRunningObjectTable::Register method call my moniker cannot bind to object. Short description on the object which being registered in ROT: HRESULT DSPPlug::FinalContruct() { CComPtr p = CreateMoniker(); ... CComPtr pIROT; ::GetRunningObjectTable(NULL,&pIROT); ... pIROT->Register(ROTFLAGS_REGISTRATIONKEEPSALIVE,this,p,&this->ROTRegValue); } void DSPPlug::FinalRelease() { CComPtr pIROT; ::GetRunningObjectTable(NULL,&pIROT); ... pIROT->Revoke(this->ROTRegValue); } Can someone help with explanation of those ? Best regards, Valery
I am as clueless as you about your problem. Would RegisterActiveObject() work for you? I don't think revoking the ROT entry to yourself i FinalRelease() is a good idea. There's a cyclic reference there. The ROT has a reference to you, and you have a reference to it. Surely, there must be a better time to release yourself...? -- Ich bin Joachim von Hassel, und ich bin Pilot der Bundeswehr. Welle: Erdball - F104-G Starfighter