Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

plugin_register "csurf_inst" produces a bug and doesn't work when called from a loaded VST3 plugin #5

Open
GZPERRA opened this issue Jan 2, 2022 · 1 comment

Comments

@GZPERRA
Copy link

GZPERRA commented Jan 2, 2022

I'm trying to register the "csurf_inst" from a loaded VST3 plugin, to listen for tracks selection changes, and it's producing a bug.
This is the code:

void registerCSurf() {
  auto reaper = // queryInterface(IReaperHostApplication::iid ...
  if (reaper)
  {
    auto registerFunc = static_cast<int (*)(const char*, void*)>(reaper->getReaperApi("plugin_register"));
    
    if (registerFunc)
    {
	    if (1 == registerFunc("csurf_inst", this)) // *this* implements IReaperControlSurface.
	    {
		    Log::debug("register csurf_inst Ok");
	    }
    }
    //reaper->release();
  }
}

The registerFunc returns 1, but no function (Run,OnTrackSelection,SetSurfaceXXX..) gets called.
But what happens is that the selection becomes broken, I can't deselect tracks, unmute ...

@justinfrankel
Copy link
Owner

justinfrankel commented May 9, 2022

It's hard to know exactly what's going on based on the limited scope of your code, but it's likely that you need to change the register line to be:
if (1 == registerFunc("csurf_inst", (void *)(IReaperControlSurface*)this))

otherwise, the cast to void * will not know which interface it should be passing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants