@@ -22,10 +22,10 @@ | |||||
#include "jackbridge/JackBridge.hpp" | #include "jackbridge/JackBridge.hpp" | ||||
#if defined(CARLA_OS_WIN) && defined(BUILDING_CARLA_FOR_WINDOWS) | #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 | #else | ||||
# define PLUGIN_BRIDGE_NAMEPREFIX_AUDIO_POOL "/crlbrdg_shm_ap_" | # define PLUGIN_BRIDGE_NAMEPREFIX_AUDIO_POOL "/crlbrdg_shm_ap_" | ||||
# define PLUGIN_BRIDGE_NAMEPREFIX_RT_CLIENT "/crlbrdg_shm_rtC_" | # define PLUGIN_BRIDGE_NAMEPREFIX_RT_CLIENT "/crlbrdg_shm_rtC_" | ||||
@@ -179,7 +179,6 @@ bool BridgeRtClientControl::initializeServer() noexcept | |||||
filename = tmpFileBase; | filename = tmpFileBase; | ||||
isServer = true; | isServer = true; | ||||
needsSemDestroy = true; | |||||
if (! mapData()) | if (! mapData()) | ||||
{ | { | ||||
@@ -207,6 +206,7 @@ bool BridgeRtClientControl::initializeServer() noexcept | |||||
return false; | return false; | ||||
} | } | ||||
needsSemDestroy = true; | |||||
return true; | return true; | ||||
} | } | ||||
@@ -22,16 +22,6 @@ | |||||
#include "CarlaMutex.hpp" | #include "CarlaMutex.hpp" | ||||
#include "CarlaString.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 | static inline | ||||
@@ -173,17 +173,37 @@ void* carla_shm_map(carla_shm_t& shm, const std::size_t size) noexcept | |||||
HANDLE map; | HANDLE map; | ||||
if (shm.isServer) | 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 | 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) | 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); | ::CloseHandle(map); | ||||
return nullptr; | return nullptr; | ||||
} | } | ||||