Browse Source

Fix bridges under windows

tags/v1.9.11
falkTX 6 years ago
parent
commit
77db511775
3 changed files with 30 additions and 20 deletions
  1. +5
    -5
      source/utils/CarlaBridgeUtils.cpp
  2. +0
    -10
      source/utils/CarlaBridgeUtils.hpp
  3. +25
    -5
      source/utils/CarlaShmUtils.hpp

+ 5
- 5
source/utils/CarlaBridgeUtils.cpp View File

@@ -22,10 +22,10 @@
#include "jackbridge/JackBridge.hpp"

#if defined(CARLA_OS_WIN) && defined(BUILDING_CARLA_FOR_WINDOWS)
# define PLUGIN_BRIDGE_NAMEPREFIX_AUDIO_POOL "Global\\carla-bridge_shm_ap_"
# define PLUGIN_BRIDGE_NAMEPREFIX_RT_CLIENT "Global\\carla-bridge_shm_rtC_"
# define PLUGIN_BRIDGE_NAMEPREFIX_NON_RT_CLIENT "Global\\carla-bridge_shm_nonrtC_"
# define PLUGIN_BRIDGE_NAMEPREFIX_NON_RT_SERVER "Global\\carla-bridge_shm_nonrtS_"
# define PLUGIN_BRIDGE_NAMEPREFIX_AUDIO_POOL "Local\\carla-bridge_shm_ap_"
# define PLUGIN_BRIDGE_NAMEPREFIX_RT_CLIENT "Local\\carla-bridge_shm_rtC_"
# define PLUGIN_BRIDGE_NAMEPREFIX_NON_RT_CLIENT "Local\\carla-bridge_shm_nonrtC_"
# define PLUGIN_BRIDGE_NAMEPREFIX_NON_RT_SERVER "Local\\carla-bridge_shm_nonrtS_"
#else
# define PLUGIN_BRIDGE_NAMEPREFIX_AUDIO_POOL "/crlbrdg_shm_ap_"
# define PLUGIN_BRIDGE_NAMEPREFIX_RT_CLIENT "/crlbrdg_shm_rtC_"
@@ -179,7 +179,6 @@ bool BridgeRtClientControl::initializeServer() noexcept

filename = tmpFileBase;
isServer = true;
needsSemDestroy = true;

if (! mapData())
{
@@ -207,6 +206,7 @@ bool BridgeRtClientControl::initializeServer() noexcept
return false;
}

needsSemDestroy = true;
return true;
}



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

@@ -22,16 +22,6 @@
#include "CarlaMutex.hpp"
#include "CarlaString.hpp"

#if defined(CARLA_OS_WIN) && defined(BUILDING_CARLA_FOR_WINDOWS)
# define PLUGIN_BRIDGE_NAMEPREFIX_RT_CLIENT "Global\\carla-bridge_shm_rtC_"
# define PLUGIN_BRIDGE_NAMEPREFIX_NON_RT_CLIENT "Global\\carla-bridge_shm_nonrtC_"
# define PLUGIN_BRIDGE_NAMEPREFIX_NON_RT_SERVER "Global\\carla-bridge_shm_nonrtS_"
#else
# define PLUGIN_BRIDGE_NAMEPREFIX_RT_CLIENT "/crlbrdg_shm_rtC_"
# define PLUGIN_BRIDGE_NAMEPREFIX_NON_RT_CLIENT "/crlbrdg_shm_nonrtC_"
# define PLUGIN_BRIDGE_NAMEPREFIX_NON_RT_SERVER "/crlbrdg_shm_nonrtS_"
#endif

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

static inline


+ 25
- 5
source/utils/CarlaShmUtils.hpp View File

@@ -173,17 +173,37 @@ void* carla_shm_map(carla_shm_t& shm, const std::size_t size) noexcept
HANDLE map;

if (shm.isServer)
map = ::CreateFileMapping(INVALID_HANDLE_VALUE, nullptr, PAGE_READWRITE|SEC_COMMIT, 0, size, shm.filename);
{
SECURITY_ATTRIBUTES sa;
carla_zeroStruct(sa);
sa.nLength = sizeof(sa);
sa.bInheritHandle = TRUE;

map = ::CreateFileMappingA(INVALID_HANDLE_VALUE, &sa, PAGE_READWRITE|SEC_COMMIT, 0, size, shm.filename);

if (map == nullptr || map == INVALID_HANDLE_VALUE)
{
const DWORD errorCode = ::GetLastError();
carla_stderr2("CreateFileMapping failed for '%s', size:%lu, isServer:%i, errorCode:%x",
shm.filename, size, shm.isServer, errorCode);
return nullptr;
}
}
else
map = ::OpenFileMapping(FILE_MAP_ALL_ACCESS, FALSE, shm.filename);
{
map = ::OpenFileMappingA(FILE_MAP_ALL_ACCESS, FALSE, shm.filename);

CARLA_SAFE_ASSERT_RETURN(map != INVALID_HANDLE_VALUE, nullptr);
CARLA_SAFE_ASSERT_RETURN(map != nullptr, nullptr);
CARLA_SAFE_ASSERT_RETURN(map != INVALID_HANDLE_VALUE, nullptr);
}

void* const ptr(::MapViewOfFile(map, FILE_MAP_ALL_ACCESS, 0, 0, size));
void* const ptr = ::MapViewOfFile(map, FILE_MAP_ALL_ACCESS, 0, 0, size);

if (ptr == nullptr)
{
carla_safe_assert("ptr != nullptr", __FILE__, __LINE__);
const DWORD errorCode = ::GetLastError();
carla_stderr2("MapViewOfFile failed for '%s', size:%lu, isServer:%i, errorCode:%u",
shm.filename, size, shm.isServer, errorCode);
::CloseHandle(map);
return nullptr;
}


Loading…
Cancel
Save