-
Notifications
You must be signed in to change notification settings - Fork 19
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
Added missing interface bindings #24
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
use crate::base::{tchar, tresult, TBool}; | ||
use crate::vst::IMessage; | ||
use vst3_com::interfaces::iunknown::IUnknown; | ||
use vst3_com::{com_interface, IID}; | ||
|
||
#[com_interface("E564A636-6A8B-8CAF-DB2D-496958E595CC")] | ||
pub trait IHostApplication: IUnknown { | ||
unsafe fn get_name(&self, name: tchar) -> tresult; | ||
unsafe fn create_instance( | ||
&self, | ||
cid: *mut IID, | ||
_iid: *mut IID, | ||
obj: *mut *mut c_void, | ||
) -> tresult; | ||
} | ||
|
||
#[inline] | ||
pub unsafe fn allocate_message(host: *mut dyn IHostApplication) -> Option<*mut dyn IMessage> { | ||
// TODO: Impl the FUID class first for Interface::iid.to_tuid to work | ||
let mut iid: IID = Default::default; | ||
// IMessage::iid.to_tuid(iid); | ||
let m: *mut IMessage = std::ptr::null_mut(); | ||
if (host.createInstance(iid, iid, m as *mut *mut c_void /* or invoke as_mut_ptr()? */) == kResultOk) { | ||
Some(m) | ||
} | ||
None | ||
} | ||
|
||
#[com_interface("61AC6ED3-85BB-7BB9-1D1C-47E229633AEC")] | ||
pub trait IVst3ToVst2Wrapper: IUnknown { } | ||
|
||
#[com_interface("44AA97B6-91B0-0B6F-C095-4688A3B8C6C5")] | ||
pub trait IVst3ToAUWrapper: IUnknown { } | ||
|
||
#[com_interface("C6F4BE93-2CB3-1B95-60C5-62426D319DC6")] | ||
pub trait IVst3ToAAXWrapper: IUnknown { } | ||
|
||
#[com_interface("E39F35F7-0088-50B7-42CF-4BF944149067")] | ||
pub trait IVst3WrapperMPESupport: IUnknown { | ||
unsafe fn enable_mpe_input_processing(&self, state: TBool) -> tresult; | ||
unsafe fn set_mpe_input_device_settings( | ||
&self, | ||
master_channel: i32, | ||
member_begin_channel: i32, | ||
member_end_channel: i32 | ||
) -> tresult; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
use crate::base::{tresult, TBool}; | ||
use vst3_com::com_interface; | ||
use vst3_com::interfaces::iunknown::IUnknown; | ||
|
||
// Defined elsewhere | ||
struct ViewRect {}; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
struct Event {}; | ||
|
||
#[com_interface("FDC8CDE2-28AE-D45B-68DF-415E0CE5743D")] | ||
pub trait IInterAppAudioHost: IUnknown { | ||
unsafe fn get_screen_size(&self, size: *mut ViewRect, scale: *mut f32) -> tresult; | ||
unsafe fn connected_to_host(&self) -> tresult; | ||
unsafe fn switch_to_host(&self) -> tresult; | ||
unsafe fn send_remote_control_event(&self, event: u32) -> tresult; | ||
unsafe fn get_host_icon(&self, icon: *mut *mut c_void) -> tresult; | ||
unsafe fn schedule_event_from_ui(&self, event: &mut Event) -> tresult; | ||
unsafe fn create_preset_manager(&self, cid: *const IID) -> Option<*mut IInterAppAudioPresetManager>; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should return |
||
unsafe fn show_settings_view(&self) -> tresult; | ||
} | ||
|
||
#[com_interface("CFD5D6D7-95B0-B50D-5FC2-4AA16020C72D")] | ||
pub trait IInterAppAudioConnectionNotification: IUnknown { | ||
unsafe fn on_inter_app_audio_connection_state_change(&self, new_state: TBool) -> tresult; | ||
} | ||
|
||
#[com_interface("DDEF3FC9-B4B3-809A-46C9-4E1DADE6FCC4")] | ||
pub trait IInterAppAudioPresetManager: IUnknown { | ||
unsafe fn run_load_preset_browser(&self) -> tresult; | ||
unsafe fn run_save_preset_browser(&self) -> tresult; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. formatting |
||
unsafe fn load_next_preset(&self) -> tresult; | ||
unsafe fn load_previous_preset(&self) -> tresult; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
use crate::base::tresult; | ||
use crate::vst::{IComponent, IEditController, IStringResult}; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
use vst3_com::com_interface; | ||
use vst3_com::interfaces::iunknown::IUnknown; | ||
|
||
#[com_interface("BAB58FD6-8F97-6E1E-4E99-430F86BE70EE")] | ||
pub trait ITestPlugProvider: IUnknown { | ||
unsafe fn get_component(&self) -> Option<*mut IComponent>; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. return *mut dyn IComponent instead of an Option |
||
unsafe fn get_controller(&self) -> Option<*mut IEditController>; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. return *mut dyn IEditController instead of an option There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @m-hilgendorf Rust's fat pointers don't behave well across language boundaries, these should return *mut c_void pointers. Here there is some more information #23 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good point! For the moment returning fat pointers "works" in that they can be cast to I think to be more explicit we should return these as pointers to vtables, which is how
Which I believe is what actually goes across the FFI boundary, and keeps the return type explicit so we don't have to cross reference source code every time we call a method. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That should work and it would be more explicit because it shows the specific interface returned! Very good! |
||
unsafe fn release_plugin(component: *mut IComponent, controller: *mut IEditController) -> tresult; | ||
unsafe const fn get_sub_categories(&self, result: &mut IStringResult) -> tresult; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove change to |
||
// unsafe const fn get_component_uid(uid: &mut FUID) -> tresult; TODO: FUID | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. use |
||
} |
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.
This implementation won't work, and we should probably write a more idiomatic Rust solution anyway. You can't call a method on
*mut dyn Interface
, it needs to be wrapped withComPtr
to handle the dispatch. When you pass in themsg
argument, it needs to be by reference cast to a void pointer (&mut iid as *mut _ as *mut c_void
).The
FUID
class doesn't need to be implemented, you can getIMessage
's IID using<IMessage as vst3_com::ComInterface>::IID
.I think this method should return
ComRc
instead ofOption<*mut dyn IMessage>
.