| 3640 | // v3_plugin_base |
| 3641 | |
| 3642 | static v3_result V3_API initialize(void* const self, v3_funknown** const context) |
| 3643 | { |
| 3644 | dpf_edit_controller* const controller = *static_cast<dpf_edit_controller**>(self); |
| 3645 | |
| 3646 | // check if already initialized |
| 3647 | #if DPF_VST3_USES_SEPARATE_CONTROLLER |
| 3648 | DISTRHO_SAFE_ASSERT_RETURN(controller->vst3 == nullptr, V3_INVALID_ARG); |
| 3649 | #else |
| 3650 | DISTRHO_SAFE_ASSERT_RETURN(! controller->initialized, V3_INVALID_ARG); |
| 3651 | #endif |
| 3652 | |
| 3653 | // query for host application |
| 3654 | v3_host_application** hostApplication = nullptr; |
| 3655 | if (context != nullptr) |
| 3656 | v3_cpp_obj_query_interface(context, v3_host_application_iid, &hostApplication); |
| 3657 | |
| 3658 | d_debug("dpf_edit_controller::initialize => %p %p | host %p", self, context, hostApplication); |
| 3659 | |
| 3660 | // save it for later so we can unref it |
| 3661 | controller->hostApplicationFromInitialize = hostApplication; |
| 3662 | |
| 3663 | #if DPF_VST3_USES_SEPARATE_CONTROLLER |
| 3664 | // provide the factory application to the plugin if this new one is missing |
| 3665 | if (hostApplication == nullptr) |
| 3666 | hostApplication = controller->hostApplicationFromFactory; |
| 3667 | |
| 3668 | // default early values |
| 3669 | if (d_nextBufferSize == 0) |
| 3670 | d_nextBufferSize = 1024; |
| 3671 | if (d_nextSampleRate <= 0.0) |
| 3672 | d_nextSampleRate = 44100.0; |
| 3673 | |
| 3674 | d_nextCanRequestParameterValueChanges = true; |
| 3675 | |
| 3676 | // create the actual plugin |
| 3677 | controller->vst3 = new PluginVst3(hostApplication, false); |
| 3678 | |
| 3679 | // set connection point if needed |
| 3680 | if (dpf_comp2ctrl_connection_point* const point = controller->connectionComp2Ctrl) |
| 3681 | { |
| 3682 | if (point->other != nullptr) |
| 3683 | controller->vst3->comp2ctrl_connect(point->other); |
| 3684 | } |
| 3685 | #else |
| 3686 | // mark as initialized |
| 3687 | controller->initialized = true; |
| 3688 | #endif |
| 3689 | |
| 3690 | return V3_OK; |
| 3691 | } |
| 3692 | |
| 3693 | static v3_result V3_API terminate(void* self) |
| 3694 | { |
no test coverage detected