Browse Source

Rename a pipe method, add docs

Signed-off-by: falkTX <falktx@falktx.com>
pull/1807/head
falkTX 1 year ago
parent
commit
04355ba2f0
Signed by: falkTX <falktx@falktx.com> GPG Key ID: CDBAA37ABC74FBA0
8 changed files with 104 additions and 75 deletions
  1. +36
    -20
      source/backend/CarlaUtils.h
  2. +26
    -26
      source/backend/engine/CarlaEngineNative.cpp
  3. +2
    -2
      source/backend/plugin/CarlaPluginLV2.cpp
  4. +16
    -4
      source/backend/utils/PipeClient.cpp
  5. +1
    -1
      source/includes/CarlaNativeExtUI.hpp
  6. +1
    -1
      source/native-plugins/midi-pattern.cpp
  7. +19
    -19
      source/utils/CarlaPipeUtils.cpp
  8. +3
    -2
      source/utils/CarlaPipeUtils.hpp

+ 36
- 20
source/backend/CarlaUtils.h View File

@@ -413,79 +413,95 @@ CARLA_PLUGIN_EXPORT void carla_juce_cleanup(void);
/* -------------------------------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------------------------------
* pipes */ * pipes */


/*!
* TODO.
*/
typedef void* CarlaPipeClientHandle; typedef void* CarlaPipeClientHandle;


/*! /*!
* TODO.
* Callback for when a message has been received (in the context of carla_pipe_client_idle()).
* If extra data is required, use any of the carla_pipe_client_readlineblock* functions.
*/ */
typedef void (*CarlaPipeCallbackFunc)(void* ptr, const char* msg); typedef void (*CarlaPipeCallbackFunc)(void* ptr, const char* msg);


/*! /*!
* TODO.
* Create and connect to pipes as used by a server.
* @a argv must match the arguments set the by server.
*/ */
CARLA_PLUGIN_EXPORT CarlaPipeClientHandle carla_pipe_client_new(const char* argv[], CarlaPipeCallbackFunc callbackFunc, void* callbackPtr);
CARLA_PLUGIN_EXPORT CarlaPipeClientHandle carla_pipe_client_new(const char* argv[],
CarlaPipeCallbackFunc callbackFunc,
void* callbackPtr);


/*! /*!
* TODO.
* Check the pipe for new messages and send them to the callback function.
*/ */
CARLA_PLUGIN_EXPORT void carla_pipe_client_idle(CarlaPipeClientHandle handle); CARLA_PLUGIN_EXPORT void carla_pipe_client_idle(CarlaPipeClientHandle handle);


/*! /*!
* TODO.
* Check if the pipe is running.
*/ */
CARLA_PLUGIN_EXPORT bool carla_pipe_client_is_running(CarlaPipeClientHandle handle); CARLA_PLUGIN_EXPORT bool carla_pipe_client_is_running(CarlaPipeClientHandle handle);


/*! /*!
* TODO.
* Lock the pipe write mutex.
*/ */
CARLA_PLUGIN_EXPORT void carla_pipe_client_lock(CarlaPipeClientHandle handle); CARLA_PLUGIN_EXPORT void carla_pipe_client_lock(CarlaPipeClientHandle handle);


/*! /*!
* TODO.
* Unlock the pipe write mutex.
*/ */
CARLA_PLUGIN_EXPORT void carla_pipe_client_unlock(CarlaPipeClientHandle handle); CARLA_PLUGIN_EXPORT void carla_pipe_client_unlock(CarlaPipeClientHandle handle);


/*! /*!
* TODO.
* Read the next line as a string.
*/ */
CARLA_PLUGIN_EXPORT const char* carla_pipe_client_readlineblock(CarlaPipeClientHandle handle, uint timeout); CARLA_PLUGIN_EXPORT const char* carla_pipe_client_readlineblock(CarlaPipeClientHandle handle, uint timeout);


/*! /*!
* Extras.
* TODO.
* Read the next line as a boolean.
*/ */
CARLA_PLUGIN_EXPORT bool carla_pipe_client_readlineblock_bool(CarlaPipeClientHandle handle, uint timeout); CARLA_PLUGIN_EXPORT bool carla_pipe_client_readlineblock_bool(CarlaPipeClientHandle handle, uint timeout);

/*!
* Read the next line as an integer.
*/
CARLA_PLUGIN_EXPORT int carla_pipe_client_readlineblock_int(CarlaPipeClientHandle handle, uint timeout); CARLA_PLUGIN_EXPORT int carla_pipe_client_readlineblock_int(CarlaPipeClientHandle handle, uint timeout);

/*!
* Read the next line as a floating point number (double precision).
*/
CARLA_PLUGIN_EXPORT double carla_pipe_client_readlineblock_float(CarlaPipeClientHandle handle, uint timeout); CARLA_PLUGIN_EXPORT double carla_pipe_client_readlineblock_float(CarlaPipeClientHandle handle, uint timeout);


/*! /*!
* TODO.
* Write a valid message.
* A valid message has only one '\n' character and it's at the end.
*/ */
CARLA_PLUGIN_EXPORT bool carla_pipe_client_write_msg(CarlaPipeClientHandle handle, const char* msg); CARLA_PLUGIN_EXPORT bool carla_pipe_client_write_msg(CarlaPipeClientHandle handle, const char* msg);


/*! /*!
* TODO.
* Write and fix a message.
*/ */
CARLA_PLUGIN_EXPORT bool carla_pipe_client_write_and_fix_msg(CarlaPipeClientHandle handle, const char* msg); CARLA_PLUGIN_EXPORT bool carla_pipe_client_write_and_fix_msg(CarlaPipeClientHandle handle, const char* msg);


/*! /*!
* TODO.
* Sync all messages currently in cache.
* This call will forcely write any messages in cache to any relevant IO.
*/ */
CARLA_PLUGIN_EXPORT bool carla_pipe_client_flush(CarlaPipeClientHandle handle);
CARLA_PLUGIN_EXPORT bool carla_pipe_client_sync(CarlaPipeClientHandle handle);


/*! /*!
* TODO.
* Convenience call for doing both sync and unlock in one-go.
*/ */
CARLA_PLUGIN_EXPORT bool carla_pipe_client_flush_and_unlock(CarlaPipeClientHandle handle);
CARLA_PLUGIN_EXPORT bool carla_pipe_client_sync_and_unlock(CarlaPipeClientHandle handle);


/*! /*!
* TODO.
* Destroy a previously created pipes instance.
*/ */
CARLA_PLUGIN_EXPORT void carla_pipe_client_destroy(CarlaPipeClientHandle handle); CARLA_PLUGIN_EXPORT void carla_pipe_client_destroy(CarlaPipeClientHandle handle);


/* DEPRECATED use carla_pipe_client_sync */
CARLA_PLUGIN_EXPORT bool carla_pipe_client_flush(CarlaPipeClientHandle handle);

/* DEPRECATED use carla_pipe_client_sync_and_unlock */
CARLA_PLUGIN_EXPORT bool carla_pipe_client_flush_and_unlock(CarlaPipeClientHandle handle);

/* -------------------------------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------------------------------
* system stuff */ * system stuff */




+ 26
- 26
source/backend/engine/CarlaEngineNative.cpp View File

@@ -432,7 +432,7 @@ protected:
std::snprintf(tmpBuf, STR_MAX, "%i\n", newBufferSize); std::snprintf(tmpBuf, STR_MAX, "%i\n", newBufferSize);


if (fUiServer.writeMessage(tmpBuf)) if (fUiServer.writeMessage(tmpBuf))
fUiServer.flushMessages();
fUiServer.syncMessages();
} }
} }
#endif #endif
@@ -461,7 +461,7 @@ protected:
} }


if (fUiServer.writeMessage(tmpBuf)) if (fUiServer.writeMessage(tmpBuf))
fUiServer.flushMessages();
fUiServer.syncMessages();
} }
} }
#endif #endif
@@ -550,7 +550,7 @@ protected:
pluginId, plugin->getMidiInCount(), plugin->getMidiOutCount()); pluginId, plugin->getMidiInCount(), plugin->getMidiOutCount());
CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(tmpBuf),); CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(tmpBuf),);


fUiServer.flushMessages();
fUiServer.syncMessages();
} }


void uiServerSendPluginParameters(const CarlaPluginPtr& plugin) void uiServerSendPluginParameters(const CarlaPluginPtr& plugin)
@@ -571,7 +571,7 @@ protected:
std::snprintf(tmpBuf, STR_MAX, "%.12g\n", static_cast<double>(plugin->getInternalParameterValue(i))); std::snprintf(tmpBuf, STR_MAX, "%.12g\n", static_cast<double>(plugin->getInternalParameterValue(i)));
CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(tmpBuf),); CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(tmpBuf),);


fUiServer.flushMessages();
fUiServer.syncMessages();
} }


uint32_t ins, outs, count; uint32_t ins, outs, count;
@@ -640,7 +640,7 @@ protected:
CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(tmpBuf),); CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(tmpBuf),);
} }


fUiServer.flushMessages();
fUiServer.syncMessages();
} }


void uiServerSendPluginPrograms(const CarlaPluginPtr& plugin) void uiServerSendPluginPrograms(const CarlaPluginPtr& plugin)
@@ -668,7 +668,7 @@ protected:
} }
} }


fUiServer.flushMessages();
fUiServer.syncMessages();


count = plugin->getMidiProgramCount(); count = plugin->getMidiProgramCount();
std::snprintf(tmpBuf, STR_MAX, "MIDI_PROGRAM_COUNT_%i:%i:%i\n", std::snprintf(tmpBuf, STR_MAX, "MIDI_PROGRAM_COUNT_%i:%i:%i\n",
@@ -688,7 +688,7 @@ protected:
CARLA_SAFE_ASSERT_RETURN(fUiServer.writeAndFixMessage(mpData.name),); CARLA_SAFE_ASSERT_RETURN(fUiServer.writeAndFixMessage(mpData.name),);
} }


fUiServer.flushMessages();
fUiServer.syncMessages();
} }


void uiServerSendPluginProperties(const CarlaPluginPtr& plugin) void uiServerSendPluginProperties(const CarlaPluginPtr& plugin)
@@ -719,7 +719,7 @@ protected:
CARLA_SAFE_ASSERT_RETURN(fUiServer.writeAndFixMessage(customData.value),); CARLA_SAFE_ASSERT_RETURN(fUiServer.writeAndFixMessage(customData.value),);
} }


fUiServer.flushMessages();
fUiServer.syncMessages();
} }


void uiServerCallback(const EngineCallbackOpcode action, const uint pluginId, void uiServerCallback(const EngineCallbackOpcode action, const uint pluginId,
@@ -829,7 +829,7 @@ protected:
CARLA_SAFE_ASSERT_RETURN(fUiServer.writeEmptyMessage(),); CARLA_SAFE_ASSERT_RETURN(fUiServer.writeEmptyMessage(),);
} }


fUiServer.flushMessages();
fUiServer.syncMessages();
} }


void uiServerInfo() void uiServerInfo()
@@ -863,7 +863,7 @@ protected:
} }
CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(tmpBuf),); CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(tmpBuf),);


fUiServer.flushMessages();
fUiServer.syncMessages();
} }


void uiServerOptions() void uiServerOptions()
@@ -885,66 +885,66 @@ protected:
CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(optionsForcedStr, optionsForcedStrSize),); CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(optionsForcedStr, optionsForcedStrSize),);
std::snprintf(tmpBuf, STR_MAX, "%i\n", options.processMode); std::snprintf(tmpBuf, STR_MAX, "%i\n", options.processMode);
CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(tmpBuf),); CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(tmpBuf),);
fUiServer.flushMessages();
fUiServer.syncMessages();


std::snprintf(tmpBuf, STR_MAX, "ENGINE_OPTION_%i\n", ENGINE_OPTION_TRANSPORT_MODE); std::snprintf(tmpBuf, STR_MAX, "ENGINE_OPTION_%i\n", ENGINE_OPTION_TRANSPORT_MODE);
CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(tmpBuf),); CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(tmpBuf),);
CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(optionsForcedStr, optionsForcedStrSize),); CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(optionsForcedStr, optionsForcedStrSize),);
std::snprintf(tmpBuf, STR_MAX, "%i\n", options.transportMode); std::snprintf(tmpBuf, STR_MAX, "%i\n", options.transportMode);
CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(tmpBuf),); CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(tmpBuf),);
fUiServer.flushMessages();
fUiServer.syncMessages();


std::snprintf(tmpBuf, STR_MAX, "ENGINE_OPTION_%i\n", ENGINE_OPTION_FORCE_STEREO); std::snprintf(tmpBuf, STR_MAX, "ENGINE_OPTION_%i\n", ENGINE_OPTION_FORCE_STEREO);
CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(tmpBuf),); CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(tmpBuf),);
CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(optionsForcedStr, optionsForcedStrSize),); CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(optionsForcedStr, optionsForcedStrSize),);
CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(options.forceStereo ? "true\n" : "false\n"),); CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(options.forceStereo ? "true\n" : "false\n"),);
fUiServer.flushMessages();
fUiServer.syncMessages();


std::snprintf(tmpBuf, STR_MAX, "ENGINE_OPTION_%i\n", ENGINE_OPTION_PREFER_PLUGIN_BRIDGES); std::snprintf(tmpBuf, STR_MAX, "ENGINE_OPTION_%i\n", ENGINE_OPTION_PREFER_PLUGIN_BRIDGES);
CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(tmpBuf),); CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(tmpBuf),);
CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(optionsForcedStr, optionsForcedStrSize),); CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(optionsForcedStr, optionsForcedStrSize),);
CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(options.preferPluginBridges ? "true\n" : "false\n"),); CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(options.preferPluginBridges ? "true\n" : "false\n"),);
fUiServer.flushMessages();
fUiServer.syncMessages();


std::snprintf(tmpBuf, STR_MAX, "ENGINE_OPTION_%i\n", ENGINE_OPTION_PREFER_UI_BRIDGES); std::snprintf(tmpBuf, STR_MAX, "ENGINE_OPTION_%i\n", ENGINE_OPTION_PREFER_UI_BRIDGES);
CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(tmpBuf),); CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(tmpBuf),);
CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(optionsForcedStr, optionsForcedStrSize),); CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(optionsForcedStr, optionsForcedStrSize),);
CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(options.preferUiBridges ? "true\n" : "false\n"),); CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(options.preferUiBridges ? "true\n" : "false\n"),);
fUiServer.flushMessages();
fUiServer.syncMessages();


std::snprintf(tmpBuf, STR_MAX, "ENGINE_OPTION_%i\n", ENGINE_OPTION_UIS_ALWAYS_ON_TOP); std::snprintf(tmpBuf, STR_MAX, "ENGINE_OPTION_%i\n", ENGINE_OPTION_UIS_ALWAYS_ON_TOP);
CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(tmpBuf),); CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(tmpBuf),);
CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(optionsForcedStr, optionsForcedStrSize),); CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(optionsForcedStr, optionsForcedStrSize),);
CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(options.uisAlwaysOnTop ? "true\n" : "false\n"),); CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(options.uisAlwaysOnTop ? "true\n" : "false\n"),);
fUiServer.flushMessages();
fUiServer.syncMessages();


std::snprintf(tmpBuf, STR_MAX, "ENGINE_OPTION_%i\n", ENGINE_OPTION_MAX_PARAMETERS); std::snprintf(tmpBuf, STR_MAX, "ENGINE_OPTION_%i\n", ENGINE_OPTION_MAX_PARAMETERS);
CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(tmpBuf),); CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(tmpBuf),);
CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(optionsForcedStr, optionsForcedStrSize),); CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(optionsForcedStr, optionsForcedStrSize),);
std::snprintf(tmpBuf, STR_MAX, "%i\n", options.maxParameters); std::snprintf(tmpBuf, STR_MAX, "%i\n", options.maxParameters);
CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(tmpBuf),); CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(tmpBuf),);
fUiServer.flushMessages();
fUiServer.syncMessages();


std::snprintf(tmpBuf, STR_MAX, "ENGINE_OPTION_%i\n", ENGINE_OPTION_UI_BRIDGES_TIMEOUT); std::snprintf(tmpBuf, STR_MAX, "ENGINE_OPTION_%i\n", ENGINE_OPTION_UI_BRIDGES_TIMEOUT);
CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(tmpBuf),); CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(tmpBuf),);
CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(optionsForcedStr, optionsForcedStrSize),); CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(optionsForcedStr, optionsForcedStrSize),);
std::snprintf(tmpBuf, STR_MAX, "%i\n", options.uiBridgesTimeout); std::snprintf(tmpBuf, STR_MAX, "%i\n", options.uiBridgesTimeout);
CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(tmpBuf),); CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(tmpBuf),);
fUiServer.flushMessages();
fUiServer.syncMessages();


std::snprintf(tmpBuf, STR_MAX, "ENGINE_OPTION_%i\n", ENGINE_OPTION_PATH_BINARIES); std::snprintf(tmpBuf, STR_MAX, "ENGINE_OPTION_%i\n", ENGINE_OPTION_PATH_BINARIES);
CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(tmpBuf),); CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(tmpBuf),);
CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage("true\n", 5),); CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage("true\n", 5),);
std::snprintf(tmpBuf, STR_MAX, "%s\n", options.binaryDir); std::snprintf(tmpBuf, STR_MAX, "%s\n", options.binaryDir);
CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(tmpBuf),); CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(tmpBuf),);
fUiServer.flushMessages();
fUiServer.syncMessages();


std::snprintf(tmpBuf, STR_MAX, "ENGINE_OPTION_%i\n", ENGINE_OPTION_PATH_RESOURCES); std::snprintf(tmpBuf, STR_MAX, "ENGINE_OPTION_%i\n", ENGINE_OPTION_PATH_RESOURCES);
CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(tmpBuf),); CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(tmpBuf),);
CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage("true\n", 5),); CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage("true\n", 5),);
std::snprintf(tmpBuf, STR_MAX, "%s\n", options.resourceDir); std::snprintf(tmpBuf, STR_MAX, "%s\n", options.resourceDir);
CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(tmpBuf),); CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(tmpBuf),);
fUiServer.flushMessages();
fUiServer.syncMessages();
} }
#endif #endif


@@ -1451,7 +1451,7 @@ protected:
CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage("runtime-info\n"),); CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage("runtime-info\n"),);
CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(tmpBuf),); CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(tmpBuf),);


fUiServer.flushMessages();
fUiServer.syncMessages();


if (const char* const projFolder = getCurrentProjectFolder()) if (const char* const projFolder = getCurrentProjectFolder())
{ {
@@ -1461,7 +1461,7 @@ protected:
fLastProjectFolder = projFolder; fLastProjectFolder = projFolder;
CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage("project-folder\n"),); CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage("project-folder\n"),);
CARLA_SAFE_ASSERT_RETURN(fUiServer.writeAndFixMessage(projFolder),); CARLA_SAFE_ASSERT_RETURN(fUiServer.writeAndFixMessage(projFolder),);
fUiServer.flushMessages();
fUiServer.syncMessages();
} }
} }


@@ -1488,7 +1488,7 @@ protected:
CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage("0.0\n"),); CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage("0.0\n"),);
} }


fUiServer.flushMessages();
fUiServer.syncMessages();


// ------------------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------------------
// send peaks and param outputs for all plugins // send peaks and param outputs for all plugins
@@ -1507,7 +1507,7 @@ protected:
static_cast<double>(plugData.peaks[3])); static_cast<double>(plugData.peaks[3]));
CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(tmpBuf),); CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(tmpBuf),);


fUiServer.flushMessages();
fUiServer.syncMessages();


for (uint32_t j=0, count=plugin->getParameterCount(); j < count; ++j) for (uint32_t j=0, count=plugin->getParameterCount(); j < count; ++j)
{ {
@@ -1519,7 +1519,7 @@ protected:
std::snprintf(tmpBuf, STR_MAX, "%.12g\n", static_cast<double>(plugin->getParameterValue(j))); std::snprintf(tmpBuf, STR_MAX, "%.12g\n", static_cast<double>(plugin->getParameterValue(j)));
CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(tmpBuf),); CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(tmpBuf),);


fUiServer.flushMessages();
fUiServer.syncMessages();
} }
} }
} }
@@ -2398,7 +2398,7 @@ bool CarlaEngineNativeUI::msgReceived(const char* const msg) noexcept
const CarlaMutexLocker cml(getPipeLock()); const CarlaMutexLocker cml(getPipeLock());


if (writeMessage("error\n", 6) && writeAndFixMessage(fEngine->getLastError())) if (writeMessage("error\n", 6) && writeAndFixMessage(fEngine->getLastError()))
flushMessages();
syncMessages();
} }


return true; return true;


+ 2
- 2
source/backend/plugin/CarlaPluginLV2.cpp View File

@@ -584,7 +584,7 @@ public:
if (! writeAndFixMessage(title)) if (! writeAndFixMessage(title))
return; return;


flushMessages();
syncMessages();
} }


protected: protected:
@@ -1946,7 +1946,7 @@ public:
if (! fPipeServer.writeMessage("show\n", 5)) if (! fPipeServer.writeMessage("show\n", 5))
return; return;


fPipeServer.flushMessages();
fPipeServer.syncMessages();
} }


#ifndef BUILD_BRIDGE #ifndef BUILD_BRIDGE


+ 16
- 4
source/backend/utils/PipeClient.cpp View File

@@ -182,19 +182,19 @@ bool carla_pipe_client_write_and_fix_msg(CarlaPipeClientHandle handle, const cha
return ((ExposedCarlaPipeClient*)handle)->writeAndFixMessage(msg); return ((ExposedCarlaPipeClient*)handle)->writeAndFixMessage(msg);
} }


bool carla_pipe_client_flush(CarlaPipeClientHandle handle)
bool carla_pipe_client_sync(CarlaPipeClientHandle handle)
{ {
CARLA_SAFE_ASSERT_RETURN(handle != nullptr, false); CARLA_SAFE_ASSERT_RETURN(handle != nullptr, false);


return ((ExposedCarlaPipeClient*)handle)->flushMessages();
return ((ExposedCarlaPipeClient*)handle)->syncMessages();
} }


bool carla_pipe_client_flush_and_unlock(CarlaPipeClientHandle handle)
bool carla_pipe_client_sync_and_unlock(CarlaPipeClientHandle handle)
{ {
CARLA_SAFE_ASSERT_RETURN(handle != nullptr, false); CARLA_SAFE_ASSERT_RETURN(handle != nullptr, false);


ExposedCarlaPipeClient* const pipe = (ExposedCarlaPipeClient*)handle; ExposedCarlaPipeClient* const pipe = (ExposedCarlaPipeClient*)handle;
const bool ret = pipe->flushMessages();
const bool ret = pipe->syncMessages();
pipe->unlockPipe(); pipe->unlockPipe();
return ret; return ret;
} }
@@ -211,6 +211,18 @@ void carla_pipe_client_destroy(CarlaPipeClientHandle handle)


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


bool carla_pipe_client_flush(CarlaPipeClientHandle handle)
{
return carla_pipe_client_sync(handle);
}

bool carla_pipe_client_flush_and_unlock(CarlaPipeClientHandle handle)
{
return carla_pipe_client_sync_and_unlock(handle);
}

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

#ifndef CARLA_PLUGIN_BUILD #ifndef CARLA_PLUGIN_BUILD
# include "CarlaPipeUtils.cpp" # include "CarlaPipeUtils.cpp"
#endif #endif


+ 1
- 1
source/includes/CarlaNativeExtUI.hpp View File

@@ -139,7 +139,7 @@ protected:
if (! writeAndFixMessage(uiName)) if (! writeAndFixMessage(uiName))
return; return;


flushMessages();
syncMessages();
} }


bool uiMIDIEvent(const uint8_t size, const uint8_t data[]) override bool uiMIDIEvent(const uint8_t size, const uint8_t data[]) override


+ 1
- 1
source/native-plugins/midi-pattern.cpp View File

@@ -353,7 +353,7 @@ protected:


CARLA_SAFE_ASSERT_RETURN(writeMessage(strBuf),); CARLA_SAFE_ASSERT_RETURN(writeMessage(strBuf),);


flushMessages();
syncMessages();
} }
} }
#endif #endif


+ 19
- 19
source/utils/CarlaPipeUtils.cpp View File

@@ -959,7 +959,7 @@ bool CarlaPipeCommon::writeEmptyMessage() const noexcept
return _writeMsgBuffer("\n", 1); return _writeMsgBuffer("\n", 1);
} }


bool CarlaPipeCommon::flushMessages() const noexcept
bool CarlaPipeCommon::syncMessages() const noexcept
{ {
CARLA_SAFE_ASSERT_RETURN(pData->pipeSend != INVALID_PIPE_VALUE, false); CARLA_SAFE_ASSERT_RETURN(pData->pipeSend != INVALID_PIPE_VALUE, false);


@@ -991,7 +991,7 @@ bool CarlaPipeCommon::writeErrorMessage(const char* const error) const noexcept
if (! writeAndFixMessage(error)) if (! writeAndFixMessage(error))
return false; return false;


flushMessages();
syncMessages();
return true; return true;
} }


@@ -1021,7 +1021,7 @@ bool CarlaPipeCommon::writeControlMessage(const uint32_t index, const float valu
if (! _writeMsgBuffer(tmpBuf, std::strlen(tmpBuf))) if (! _writeMsgBuffer(tmpBuf, std::strlen(tmpBuf)))
return false; return false;


flushMessages();
syncMessages();
return true; return true;
} }


@@ -1039,7 +1039,7 @@ bool CarlaPipeCommon::writeConfigureMessage(const char* const key, const char* c
if (! writeAndFixMessage(value)) if (! writeAndFixMessage(value))
return false; return false;


flushMessages();
syncMessages();
return true; return true;
} }


@@ -1057,7 +1057,7 @@ bool CarlaPipeCommon::writeProgramMessage(const uint32_t index) const noexcept
if (! _writeMsgBuffer(tmpBuf, std::strlen(tmpBuf))) if (! _writeMsgBuffer(tmpBuf, std::strlen(tmpBuf)))
return false; return false;


flushMessages();
syncMessages();
return true; return true;
} }


@@ -1083,7 +1083,7 @@ bool CarlaPipeCommon::writeProgramMessage(const uint8_t channel, const uint32_t
if (! _writeMsgBuffer(tmpBuf, std::strlen(tmpBuf))) if (! _writeMsgBuffer(tmpBuf, std::strlen(tmpBuf)))
return false; return false;


flushMessages();
syncMessages();
return true; return true;
} }


@@ -1105,7 +1105,7 @@ bool CarlaPipeCommon::writeMidiProgramMessage(const uint32_t bank, const uint32_
if (! _writeMsgBuffer(tmpBuf, std::strlen(tmpBuf))) if (! _writeMsgBuffer(tmpBuf, std::strlen(tmpBuf)))
return false; return false;


flushMessages();
syncMessages();
return true; return true;
} }


@@ -1123,7 +1123,7 @@ bool CarlaPipeCommon::writeReloadProgramsMessage(const int32_t index) const noex
if (! _writeMsgBuffer(tmpBuf, std::strlen(tmpBuf))) if (! _writeMsgBuffer(tmpBuf, std::strlen(tmpBuf)))
return false; return false;


flushMessages();
syncMessages();
return true; return true;
} }


@@ -1157,7 +1157,7 @@ bool CarlaPipeCommon::writeMidiNoteMessage(const bool onOff, const uint8_t chann
if (! _writeMsgBuffer(tmpBuf, std::strlen(tmpBuf))) if (! _writeMsgBuffer(tmpBuf, std::strlen(tmpBuf)))
return false; return false;


flushMessages();
syncMessages();
return true; return true;
} }


@@ -1191,7 +1191,7 @@ bool CarlaPipeCommon::writeLv2AtomMessage(const uint32_t index, const LV2_Atom*
if (! writeAndFixMessage(base64atom.buffer())) if (! writeAndFixMessage(base64atom.buffer()))
return false; return false;


flushMessages();
syncMessages();
return true; return true;
} }


@@ -1220,7 +1220,7 @@ bool CarlaPipeCommon::writeLv2ParameterMessage(const char* const uri, const floa
if (! _writeMsgBuffer(tmpBuf, std::strlen(tmpBuf))) if (! _writeMsgBuffer(tmpBuf, std::strlen(tmpBuf)))
return false; return false;


flushMessages();
syncMessages();
return true; return true;
} }


@@ -1248,7 +1248,7 @@ bool CarlaPipeCommon::writeLv2UridMessage(const uint32_t urid, const char* const
if (! writeAndFixMessage(uri)) if (! writeAndFixMessage(uri))
return false; return false;


flushMessages();
syncMessages();
return true; return true;
} }


@@ -1778,7 +1778,7 @@ void CarlaPipeServer::stopPipeServer(const uint32_t timeOutMilliseconds) noexcep
if (pData->pipeSend != INVALID_PIPE_VALUE && ! pData->pipeClosed) if (pData->pipeSend != INVALID_PIPE_VALUE && ! pData->pipeClosed)
{ {
if (_writeMsgBuffer("__carla-quit__\n", 15)) if (_writeMsgBuffer("__carla-quit__\n", 15))
flushMessages();
syncMessages();
} }


waitForProcessToStopOrKillIt(pData->processInfo.hProcess, timeOutMilliseconds); waitForProcessToStopOrKillIt(pData->processInfo.hProcess, timeOutMilliseconds);
@@ -1796,7 +1796,7 @@ void CarlaPipeServer::stopPipeServer(const uint32_t timeOutMilliseconds) noexcep
if (pData->pipeSend != INVALID_PIPE_VALUE && ! pData->pipeClosed) if (pData->pipeSend != INVALID_PIPE_VALUE && ! pData->pipeClosed)
{ {
if (_writeMsgBuffer("__carla-quit__\n", 15)) if (_writeMsgBuffer("__carla-quit__\n", 15))
flushMessages();
syncMessages();
} }


waitForChildToStopOrKillIt(pData->pid, timeOutMilliseconds); waitForChildToStopOrKillIt(pData->pid, timeOutMilliseconds);
@@ -1847,7 +1847,7 @@ void CarlaPipeServer::writeShowMessage() const noexcept
if (! _writeMsgBuffer("show\n", 5)) if (! _writeMsgBuffer("show\n", 5))
return; return;


flushMessages();
syncMessages();
} }


void CarlaPipeServer::writeFocusMessage() const noexcept void CarlaPipeServer::writeFocusMessage() const noexcept
@@ -1857,7 +1857,7 @@ void CarlaPipeServer::writeFocusMessage() const noexcept
if (! _writeMsgBuffer("focus\n", 6)) if (! _writeMsgBuffer("focus\n", 6))
return; return;


flushMessages();
syncMessages();
} }


void CarlaPipeServer::writeHideMessage() const noexcept void CarlaPipeServer::writeHideMessage() const noexcept
@@ -1867,7 +1867,7 @@ void CarlaPipeServer::writeHideMessage() const noexcept
if (! _writeMsgBuffer("show\n", 5)) if (! _writeMsgBuffer("show\n", 5))
return; return;


flushMessages();
syncMessages();
} }


// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
@@ -1937,7 +1937,7 @@ bool CarlaPipeClient::initPipeClient(const char* argv[]) noexcept
pData->clientClosingDown = false; pData->clientClosingDown = false;


if (writeMessage("\n", 1)) if (writeMessage("\n", 1))
flushMessages();
syncMessages();


return true; return true;
} }
@@ -1977,7 +1977,7 @@ void CarlaPipeClient::writeExitingMessageAndWait() noexcept
const CarlaMutexLocker cml(pData->writeLock); const CarlaMutexLocker cml(pData->writeLock);


if (_writeMsgBuffer("exiting\n", 8)) if (_writeMsgBuffer("exiting\n", 8))
flushMessages();
syncMessages();
} }


// NOTE: no more messages are handled after this point // NOTE: no more messages are handled after this point


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

@@ -175,9 +175,10 @@ public:
bool writeEmptyMessage() const noexcept; bool writeEmptyMessage() const noexcept;


/*! /*!
* Flush all messages currently in cache.
* Sync all messages currently in cache.
* This call will forcely write any messages in cache to any relevant IO.
*/ */
bool flushMessages() const noexcept;
bool syncMessages() const noexcept;


// ------------------------------------------------------------------- // -------------------------------------------------------------------
// write prepared messages, no lock or flush needed (done internally) // write prepared messages, no lock or flush needed (done internally)


Loading…
Cancel
Save