Skip to main content

build_document_controller_instance

Function build_document_controller_instance 

Source
pub fn build_document_controller_instance(
    controller: Box<dyn DocumentController>,
) -> *const ARADocumentControllerInstance
Expand description

Build a C-compatible ARADocumentControllerInstance from a trait object.

Returns a heap-allocated instance that the DAW will destroy by calling the destroyDocumentController vtable entry. The returned pointer should be returned from your ARAFactory::createDocumentControllerWithDocument callback.

§Safety

The returned pointer must eventually be freed by the DAW calling destroyDocumentController. If the DAW never calls it, the memory will leak.

§Example

use ara2_bridge::*;
use ara2_bridge_sys::*;

unsafe extern "C" fn factory_callback(
    _host: *const ARADocumentControllerHostInstance,
    _props: *const ARADocumentProperties,
) -> *const ARADocumentControllerInstance {
    let controller = Box::new(MyPlugin);
    build_document_controller_instance(controller)
}