Browse Source

Fix possible locale issues when using carla as plugin

tags/1.9.5
falkTX 10 years ago
parent
commit
95b8ae0b77
3 changed files with 44 additions and 17 deletions
  1. +1
    -0
      source/Makefile.mk
  2. +16
    -15
      source/backend/engine/CarlaEngineNative.cpp
  3. +27
    -2
      source/utils/CarlaPipeUtils.hpp

+ 1
- 0
source/Makefile.mk View File

@@ -128,6 +128,7 @@ ifeq ($(LINUX),true)
CFLAGS += -isystem /opt/kxstudio/include
CXXFLAGS += -isystem /opt/kxstudio/include
CXXFLAGS += -isystem /opt/kxstudio/include/ntk
CXXFLAGS += -isystem /opt/kxstudio-trusty/include/ntk
CXXFLAGS += -isystem /usr/include/qt4
endif
ifeq ($(MACOS),true)


+ 16
- 15
source/backend/engine/CarlaEngineNative.cpp View File

@@ -788,6 +788,7 @@ protected:
void uiServerSendPluginParameters(CarlaPlugin* const plugin)
{
const CarlaMutexLocker cml(fUiServer.getWriteLock());
const ScopedLocale csl;

const uint pluginId(plugin->getId());

@@ -917,6 +918,7 @@ protected:
}

const CarlaMutexLocker cml(fUiServer.getWriteLock());
const ScopedLocale csl;

std::sprintf(fTmpBuf, "ENGINE_CALLBACK_%i\n", int(action));
fUiServer.writeMsg(fTmpBuf);
@@ -1387,32 +1389,31 @@ protected:
if (! fUiServer.isOk())
return;

for (uint i=0; i < pData->curPluginCount; ++i)
{
const EnginePluginData& plugData(pData->plugins[i]);
const CarlaPlugin* const plugin(pData->plugins[i].plugin);
const CarlaMutexLocker cml(fUiServer.getWriteLock());
const ScopedLocale csl;

for (uint i=0; i < pData->curPluginCount; ++i)
{
const CarlaMutexLocker cml(fUiServer.getWriteLock());
const EnginePluginData& plugData(pData->plugins[i]);
const CarlaPlugin* const plugin(pData->plugins[i].plugin);

std::sprintf(fTmpBuf, "PEAKS_%i\n", i);
fUiServer.writeMsg(fTmpBuf);

std::sprintf(fTmpBuf, "%f:%f:%f:%f\n", plugData.insPeak[0], plugData.insPeak[1], plugData.outsPeak[0], plugData.outsPeak[1]);
fUiServer.writeMsg(fTmpBuf);
}

for (uint32_t j=0, count=plugin->getParameterCount(); j < count; ++j)
{
if (! plugin->isParameterOutput(j))
continue;

const CarlaMutexLocker cml(fUiServer.getWriteLock());
for (uint32_t j=0, count=plugin->getParameterCount(); j < count; ++j)
{
if (! plugin->isParameterOutput(j))
continue;

std::sprintf(fTmpBuf, "PARAMVAL_%i:%i\n", i, j);
fUiServer.writeMsg(fTmpBuf);
std::sprintf(fTmpBuf, "%f\n", plugin->getParameterValue(j));
fUiServer.writeMsg(fTmpBuf);
std::sprintf(fTmpBuf, "PARAMVAL_%i:%i\n", i, j);
fUiServer.writeMsg(fTmpBuf);
std::sprintf(fTmpBuf, "%f\n", plugin->getParameterValue(j));
fUiServer.writeMsg(fTmpBuf);
}
}
}



+ 27
- 2
source/utils/CarlaPipeUtils.hpp View File

@@ -35,6 +35,31 @@

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

struct ScopedLocale {
const char* locale;

ScopedLocale() noexcept
: locale(carla_strdup_safe(::setlocale(LC_NUMERIC, nullptr)))
{
::setlocale(LC_NUMERIC, "C");
}

~ScopedLocale() noexcept
{
if (locale != nullptr)
{
::setlocale(LC_NUMERIC, locale);
delete[] locale;
locale = nullptr;
}
}

CARLA_DECLARE_NON_COPY_STRUCT(ScopedLocale)
CARLA_PREVENT_HEAP_ALLOCATION
};

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

class CarlaPipeServer
{
protected:
@@ -273,8 +298,8 @@ public:

if (locale == nullptr)
{
locale = carla_strdup(setlocale(LC_NUMERIC, nullptr));
::setlocale(LC_NUMERIC, "POSIX");
locale = carla_strdup(::setlocale(LC_NUMERIC, nullptr));
::setlocale(LC_NUMERIC, "C");
}

fIsReading = true;


Loading…
Cancel
Save