Browse Source

Cleanup

tags/v1.9.11
falkTX 6 years ago
parent
commit
f99242e2bc
3 changed files with 35 additions and 53 deletions
  1. +5
    -53
      source/includes/CarlaNativeExtUI.hpp
  2. +25
    -0
      source/utils/CarlaPipeUtils.cpp
  3. +5
    -0
      source/utils/CarlaPipeUtils.hpp

+ 5
- 53
source/includes/CarlaNativeExtUI.hpp View File

@@ -33,13 +33,13 @@ class NativePluginAndUiClass : public NativePluginClass,
public CarlaExternalUI
{
public:
NativePluginAndUiClass(const NativeHostDescriptor* const host, const char* const extUiPath)
NativePluginAndUiClass(const NativeHostDescriptor* const host, const char* const pathToExternalUI)
: NativePluginClass(host),
CarlaExternalUI(),
fExtUiPath(getResourceDir())
{
fExtUiPath += CARLA_OS_SEP_STR;
fExtUiPath += extUiPath;
fExtUiPath += pathToExternalUI;
#ifdef CARLA_OS_WIN
fExtUiPath += ".exe";
#endif
@@ -104,53 +104,14 @@ protected:
{
CARLA_SAFE_ASSERT_RETURN(index < getParameterCount(),);

// TODO writeControlMessage and others

char tmpBuf[0xff+1];
tmpBuf[0xff] = '\0';

const CarlaMutexLocker cml(getPipeLock());
const ScopedLocale csl;

if (! writeMessage("control\n", 8))
return;

std::snprintf(tmpBuf, 0xff, "%i\n", index);
if (! writeMessage(tmpBuf))
return;

std::snprintf(tmpBuf, 0xff, "%f\n", value);
if (! writeMessage(tmpBuf))
return;

flushMessages();
writeControlMessage(index, value);
}

void uiSetMidiProgram(const uint8_t channel, const uint32_t bank, const uint32_t program) noexcept override
{
CARLA_SAFE_ASSERT_RETURN(channel < MAX_MIDI_CHANNELS,);

char tmpBuf[0xff+1];
tmpBuf[0xff] = '\0';

const CarlaMutexLocker cml(getPipeLock());

if (! writeMessage("program\n", 8))
return;

std::snprintf(tmpBuf, 0xff, "%i\n", channel);
if (! writeMessage(tmpBuf))
return;

std::snprintf(tmpBuf, 0xff, "%i\n", bank);
if (! writeMessage(tmpBuf))
return;

std::snprintf(tmpBuf, 0xff, "%i\n", program);
if (! writeMessage(tmpBuf))
return;

flushMessages();
writeProgramMessage(channel, bank, program);
}

void uiSetCustomData(const char* const key, const char* const value) noexcept override
@@ -158,16 +119,7 @@ protected:
CARLA_SAFE_ASSERT_RETURN(key != nullptr && key[0] != '\0',);
CARLA_SAFE_ASSERT_RETURN(value != nullptr,);

const CarlaMutexLocker cml(getPipeLock());

if (! writeMessage("configure\n", 10))
return;
if (! writeAndFixMessage(key))
return;
if (! writeAndFixMessage(value))
return;

flushMessages();
writeConfigureMessage(key, value);
}

void uiNameChanged(const char* const uiName) override


+ 25
- 0
source/utils/CarlaPipeUtils.cpp View File

@@ -855,6 +855,31 @@ void CarlaPipeCommon::writeProgramMessage(const uint32_t index) const noexcept
flushMessages();
}

void CarlaPipeCommon::writeProgramMessage(const uint8_t channel, const uint32_t bank, const uint32_t program) const noexcept
{
char tmpBuf[0xff+1];
tmpBuf[0xff] = '\0';

const CarlaMutexLocker cml(pData->writeLock);

if (! _writeMsgBuffer("program\n", 8))
return;

std::snprintf(tmpBuf, 0xff, "%i\n", channel);
if (! _writeMsgBuffer(tmpBuf, std::strlen(tmpBuf)))
return;

std::snprintf(tmpBuf, 0xff, "%i\n", bank);
if (! _writeMsgBuffer(tmpBuf, std::strlen(tmpBuf)))
return;

std::snprintf(tmpBuf, 0xff, "%i\n", program);
if (! _writeMsgBuffer(tmpBuf, std::strlen(tmpBuf)))
return;

flushMessages();
}

void CarlaPipeCommon::writeMidiProgramMessage(const uint32_t bank, const uint32_t program) const noexcept
{
char tmpBuf[0xff+1];


+ 5
- 0
source/utils/CarlaPipeUtils.hpp View File

@@ -192,6 +192,11 @@ public:
*/
void writeProgramMessage(const uint32_t index) const noexcept;

/*!
* Write a "program" message (using channel, bank and program).
*/
void writeProgramMessage(const uint8_t channel, const uint32_t bank, const uint32_t program) const noexcept;

/*!
* Write a "midiprogram" message (using bank and program).
*/


Loading…
Cancel
Save