Browse Source

Allow carla-plugin to have full access to Host API

Signed-off-by: falkTX <falktx@falktx.com>
tags/v2.2.0-RC1
falkTX 4 years ago
parent
commit
8db6aa98e2
Signed by: falkTX <falktx@falktx.com> GPG Key ID: CDBAA37ABC74FBA0
2 changed files with 44 additions and 3 deletions
  1. +17
    -3
      source/includes/CarlaNativePlugin.h
  2. +27
    -0
      source/plugin/carla-native-plugin.cpp

+ 17
- 3
source/includes/CarlaNativePlugin.h View File

@@ -1,6 +1,6 @@
/*
* Carla Plugin Host
* Copyright (C) 2011-2019 Filipe Coelho <falktx@falktx.com>
* Copyright (C) 2011-2020 Filipe Coelho <falktx@falktx.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
@@ -18,8 +18,8 @@
#ifndef CARLA_NATIVE_PLUGIN_H_INCLUDED
#define CARLA_NATIVE_PLUGIN_H_INCLUDED

#include "CarlaBackend.h"
#include "CarlaNative.h"
#include "CarlaHost.h"

#ifndef CARLA_HOST_H_INCLUDED
#ifndef CARLA_UTILS_H_INCLUDED
@@ -65,11 +65,25 @@ CARLA_EXPORT const NativePluginDescriptor* carla_get_native_patchbay64_plugin(vo
*/
CARLA_EXPORT const NativePluginDescriptor* carla_get_native_patchbay_cv_plugin(void);

/*!
* Create a CarlaHostHandle suitable for CarlaHost API calls.
* Returned value must be freed by the caller when no longer needed.
*/
CARLA_EXPORT CarlaHostHandle carla_create_native_plugin_host_handle(const NativePluginDescriptor* desc,
NativePluginHandle handle);

/*!
* Free memory created during carla_create_native_plugin_host_handle.
*/
CARLA_EXPORT void carla_host_handle_free(CarlaHostHandle handle);

#ifdef __cplusplus
/*!
* Get the internal CarlaEngine instance.
* @deprecated Please use carla_create_native_plugin_host_handle instead
*/
CARLA_EXPORT CarlaBackend::CarlaEngine* carla_get_native_plugin_engine(const NativePluginDescriptor* desc, NativePluginHandle handle);
CARLA_EXPORT CarlaBackend::CarlaEngine* carla_get_native_plugin_engine(const NativePluginDescriptor* desc,
NativePluginHandle handle);
#endif

#endif /* CARLA_NATIVE_PLUGIN_H_INCLUDED */

+ 27
- 0
source/plugin/carla-native-plugin.cpp View File

@@ -16,6 +16,7 @@
*/

#include "CarlaNativePlugin.h"
#include "CarlaHostImpl.hpp"

#include "CarlaEngine.hpp"
#include "CarlaString.hpp"
@@ -26,6 +27,32 @@ CARLA_BACKEND_USE_NAMESPACE

// --------------------------------------------------------------------------------------------------------------------

CarlaHostHandle carla_create_native_plugin_host_handle(const NativePluginDescriptor* desc, NativePluginHandle handle)
{
CarlaEngine* const engine = carla_get_native_plugin_engine(desc, handle);
CARLA_SAFE_ASSERT_RETURN(engine, nullptr);

CarlaHostHandleImpl* hosthandle;

try {
hosthandle = new CarlaHostHandleImpl();
} CARLA_SAFE_EXCEPTION_RETURN("carla_create_native_plugin_host_handle()", nullptr);

hosthandle->engine = engine;
hosthandle->isPlugin = true;
return hosthandle;
}

void carla_host_handle_free(CarlaHostHandle handle)
{
CARLA_SAFE_ASSERT_RETURN(handle != nullptr,);
CARLA_SAFE_ASSERT_RETURN(handle->isPlugin,);

delete (CarlaHostHandleImpl*)handle;
}

// --------------------------------------------------------------------------------------------------------------------

CarlaEngine* carla_get_native_plugin_engine(const NativePluginDescriptor* desc, NativePluginHandle handle)
{
CARLA_SAFE_ASSERT_RETURN(desc != nullptr, nullptr);


Loading…
Cancel
Save