-
Notifications
You must be signed in to change notification settings - Fork 91
Implement a few editor related functions for PluginInstance #136
Conversation
src/host.rs
Outdated
| self.dispatch(plugin::OpCode::EditorGetRect, 0, 0, rect_ptr as *mut c_void, 0.0); | ||
|
|
||
| if rect != std::ptr::null_mut() { | ||
| Some(unsafe{ *rect }) // TODO: Who owns rect? Who should free the memory? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since rect is a pointer to a heap allocated editor::Rect, I presume the plugin is going to allocate the memory and set it to the correct value, but I'm not sure whether or when should we free the memory.
Appreciate any advice.
askeksa
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These editor functions are already present in the Editor trait, available through the get_editor method on the Plugin trait. They need to be separate from the Plugin trait because they are called concurrently with the processing methods of Plugin.
For more information about the background behind this design and why the methods were moved out of the Plugin trait, see #49 and #65.
The proper way to add editor support to the PluginInstance will be to implement the get_editor method to return an Editor implementation that dispatches to the editor-related opcodes. It can contain an Arc<PluginParametersInstance> and call the dispatch method on that.
|
Thanks for the info @askeksa ! I've moved the functions into a new |
askeksa
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
One comment about the PluginEditor struct, otherwise it looks good!
This pull request implements a few editor related functions for
PluginInstance:get_editor_rect()open_editor()close_editor()I'm writing a VST plugin host GUI application using
vst-rsand find these functions useful.