Skip to content
This repository has been archived by the owner on Mar 27, 2024. It is now read-only.

Implement a few editor related functions for PluginInstance #136

Merged
merged 4 commits into from
Nov 7, 2020
Merged

Implement a few editor related functions for PluginInstance #136

merged 4 commits into from
Nov 7, 2020

Conversation

eyeplum
Copy link
Contributor

@eyeplum eyeplum commented Oct 21, 2020

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-rs and find these functions useful.

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?
Copy link
Contributor Author

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.

Copy link
Contributor

@askeksa askeksa left a 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.

@eyeplum
Copy link
Contributor Author

eyeplum commented Oct 24, 2020

Thanks for the info @askeksa !

I've moved the functions into a new PluginEditor struct which implements the Editor trait.

Copy link
Contributor

@askeksa askeksa left a 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!

src/host.rs Outdated Show resolved Hide resolved
@askeksa askeksa merged commit bec471c into RustAudio:master Nov 7, 2020
askeksa pushed a commit to askeksa/vst-rs that referenced this pull request Nov 7, 2020
@eyeplum eyeplum deleted the host branch November 8, 2020 00:42
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants