Browse Source

Some more plugin bridge work

tags/1.9.4
falkTX 10 years ago
parent
commit
43038eeb68
5 changed files with 330 additions and 315 deletions
  1. +1
    -1
      source/backend/Makefile.mk
  2. +1
    -2
      source/backend/engine/CarlaEngine.cpp
  3. +306
    -297
      source/backend/plugin/BridgePlugin.cpp
  4. +1
    -0
      source/utils/CarlaBridgeUtils.hpp
  5. +21
    -15
      source/utils/CarlaShmUtils.hpp

+ 1
- 1
source/backend/Makefile.mk View File

@@ -78,7 +78,7 @@ LINKED_LIST_HPP = ../../utils/LinkedList.hpp $(CARLA_UTILS_HPP)
RT_LINKED_LIST_HPP = ../../utils/RtLinkedList.hpp $(LINKED_LIST_HPP)

CARLA_BACKEND_UTILS_HPP = ../../utils/CarlaBackendUtils.hpp $(CARLA_BACKEND_H) $(CARLA_HOST_H) $(CARLA_STRING_HPP)
CARLA_BRIDGE_UTILS_HPP = ../../utils/CarlaBridgeUtils.hpp $(CARLA_RING_BUFFER_HPP)
CARLA_BRIDGE_UTILS_HPP = ../../utils/CarlaBridgeUtils.hpp $(CARLA_BACKEND_H) $(CARLA_RING_BUFFER_HPP)
CARLA_ENGINE_UTILS_HPP = ../../utils/CarlaEngineUtils.hpp $(CARLA_ENGINE_HPP) $(CARLA_UTILS_HPP)
CARLA_LIB_COUNTER_HPP = ../../utils/CarlaLibCounter.hpp $(CARLA_LIB_UTILS_HPP) $(CARLA_MUTEX_HPP) $(LINKED_LIST_HPP)
CARLA_MATH_UTILS_HPP = ../../utils/CarlaMathUtils.hpp $(CARLA_UTILS_HPP)


+ 1
- 2
source/backend/engine/CarlaEngine.cpp View File

@@ -793,7 +793,7 @@ bool CarlaEngine::addPlugin(const BinaryType btype, const PluginType ptype, cons

if (btype != BINARY_NATIVE || (pData->options.preferPluginBridges && bridgeBinary.isNotEmpty()))
{
if (bridgeBinary != nullptr)
if (bridgeBinary.isNotEmpty())
{
plugin = CarlaPlugin::newBridge(initializer, btype, ptype, bridgeBinary.getBuffer());
}
@@ -2315,7 +2315,6 @@ void CarlaEngine::oscSend_bridge_parameter_value(const uint32_t index, const flo
CARLA_SAFE_ASSERT_RETURN(pData->oscData != nullptr,);
CARLA_SAFE_ASSERT_RETURN(pData->oscData->path != nullptr && pData->oscData->path[0] != '\0',);
CARLA_SAFE_ASSERT_RETURN(pData->oscData->target != nullptr,);
CARLA_SAFE_ASSERT_RETURN(index != PARAMETER_NULL,);
carla_debug("CarlaEngine::oscSend_bridge_parameter_value(%i, %f)", index, value);

char targetPath[std::strlen(pData->oscData->path)+24];


+ 306
- 297
source/backend/plugin/BridgePlugin.cpp
File diff suppressed because it is too large
View File


+ 1
- 0
source/utils/CarlaBridgeUtils.hpp View File

@@ -18,6 +18,7 @@
#ifndef CARLA_BRIDGE_UTILS_HPP_INCLUDED
#define CARLA_BRIDGE_UTILS_HPP_INCLUDED

#include "CarlaBackend.h"
#include "CarlaRingBuffer.hpp"

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


+ 21
- 15
source/utils/CarlaShmUtils.hpp View File

@@ -1,6 +1,6 @@
/*
* Carla shared memory utils
* Copyright (C) 2013 Filipe Coelho <falktx@falktx.com>
* Copyright (C) 2013-2014 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
@@ -28,6 +28,12 @@ struct shm_t { HANDLE shm; HANDLE map; };
typedef int shm_t;
#endif

#ifdef CARLA_OS_WIN
static shm_t gNullCarlaShm = { nullptr, nullptr };
#else
static shm_t gNullCarlaShm = -1;
#endif

// -----------------------------------------------------------------------
// shared memory calls

@@ -56,7 +62,7 @@ void carla_shm_init(shm_t& shm)
static inline
shm_t carla_shm_create(const char* const name)
{
CARLA_ASSERT(name != nullptr);
CARLA_SAFE_ASSERT_RETURN(name != nullptr && name[0] != '\0', gNullShm);

shm_t ret;
ret.shm = nullptr; // TODO
@@ -68,7 +74,7 @@ shm_t carla_shm_create(const char* const name)
static inline
shm_t carla_shm_attach(const char* const name)
{
CARLA_ASSERT(name != nullptr);
CARLA_SAFE_ASSERT_RETURN(name != nullptr && name[0] != '\0', gNullShm);

shm_t ret;
ret.shm = CreateFileA(name, GENERIC_READ|GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL);
@@ -80,7 +86,7 @@ shm_t carla_shm_attach(const char* const name)
static inline
shm_t carla_shm_attach_linux(const char* const name)
{
CARLA_ASSERT(name != nullptr);
CARLA_SAFE_ASSERT_RETURN(name != nullptr && name[0] != '\0', gNullShm);

char shmName[std::strlen(name)+10];
std::strcpy(shmName, "/dev/shm/");
@@ -96,7 +102,7 @@ shm_t carla_shm_attach_linux(const char* const name)
static inline
shm_t carla_shm_create(const char* const name)
{
CARLA_ASSERT(name != nullptr);
CARLA_SAFE_ASSERT_RETURN(name != nullptr && name[0] != '\0', -1);

return shm_open(name, O_RDWR|O_CREAT|O_EXCL, 0600);
}
@@ -104,7 +110,7 @@ shm_t carla_shm_create(const char* const name)
static inline
shm_t carla_shm_attach(const char* const name)
{
CARLA_ASSERT(name != nullptr);
CARLA_SAFE_ASSERT_RETURN(name != nullptr && name[0] != '\0', -1);

return shm_open(name, O_RDWR, 0);
}
@@ -113,10 +119,10 @@ shm_t carla_shm_attach(const char* const name)
static inline
void carla_shm_close(shm_t& shm)
{
CARLA_ASSERT(carla_is_shm_valid(shm));
CARLA_SAFE_ASSERT_RETURN(carla_is_shm_valid(shm),);

#ifdef CARLA_OS_WIN
CARLA_ASSERT(shm.map == nullptr);
CARLA_SAFE_ASSERT_RETURN(shm.map == nullptr,);

CloseHandle(shm.shm);
shm.shm = nullptr;
@@ -129,11 +135,11 @@ void carla_shm_close(shm_t& shm)
static inline
void* carla_shm_map(shm_t& shm, const size_t size)
{
CARLA_ASSERT(carla_is_shm_valid(shm));
CARLA_ASSERT(size > 0);
CARLA_SAFE_ASSERT_RETURN(carla_is_shm_valid(shm), nullptr);
CARLA_SAFE_ASSERT_RETURN(size > 0, nullptr);

#ifdef CARLA_OS_WIN
CARLA_ASSERT(shm.map == nullptr);
CARLA_SAFE_ASSERT_RETURN(shm.map == nullptr, nullptr);

HANDLE map = CreateFileMapping(shm.shm, NULL, PAGE_READWRITE, size, size, NULL);

@@ -162,12 +168,12 @@ void* carla_shm_map(shm_t& shm, const size_t size)
static inline
void carla_shm_unmap(shm_t& shm, void* const ptr, const size_t size)
{
CARLA_ASSERT(carla_is_shm_valid(shm));
CARLA_ASSERT(ptr != nullptr);
CARLA_ASSERT(size > 0);
CARLA_SAFE_ASSERT_RETURN(carla_is_shm_valid(shm),);
CARLA_SAFE_ASSERT_RETURN(ptr != nullptr,);
CARLA_SAFE_ASSERT_RETURN(size > 0,);

#ifdef CARLA_OS_WIN
CARLA_ASSERT(shm.map != nullptr);
CARLA_SAFE_ASSERT_RETURN(shm.map != nullptr,);

UnmapViewOfFile(ptr);
CloseHandle(shm.map);


Loading…
Cancel
Save