Browse Source

Properly wait for ui-bridges to get all messages, fixes #159 (I hope)

tags/1.9.6
falkTX 10 years ago
parent
commit
5aaa500dc0
3 changed files with 22 additions and 5 deletions
  1. +6
    -2
      source/backend/plugin/CarlaPluginLV2.cpp
  2. +15
    -3
      source/bridges-ui/CarlaBridgeUI.cpp
  3. +1
    -0
      source/bridges-ui/CarlaBridgeUI.hpp

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

@@ -1493,6 +1493,10 @@ public:
break; break;
} }
} }
else
{
// TODO - detect if ui-bridge crashed
}


if (fUI.handle != nullptr && fUI.descriptor != nullptr) if (fUI.handle != nullptr && fUI.descriptor != nullptr)
{ {
@@ -4461,7 +4465,7 @@ public:
{ {
CARLA_SAFE_ASSERT_RETURN(fUI.type == UI::TYPE_EMBED,); CARLA_SAFE_ASSERT_RETURN(fUI.type == UI::TYPE_EMBED,);
CARLA_SAFE_ASSERT_RETURN(fUI.window != nullptr,); CARLA_SAFE_ASSERT_RETURN(fUI.window != nullptr,);
carla_stdout("CarlaPluginLV2::handlePluginUIResized(%u, %u)", width, height);
carla_debug("CarlaPluginLV2::handlePluginUIResized(%u, %u)", width, height);


if (fUI.handle != nullptr && fExt.uiresize != nullptr) if (fUI.handle != nullptr && fExt.uiresize != nullptr)
fExt.uiresize->ui_resize(fUI.handle, static_cast<int>(width), static_cast<int>(height)); fExt.uiresize->ui_resize(fUI.handle, static_cast<int>(width), static_cast<int>(height));
@@ -5441,7 +5445,7 @@ public:
{ {
CARLA_SAFE_ASSERT_RETURN(urid != CARLA_URI_MAP_ID_NULL,); CARLA_SAFE_ASSERT_RETURN(urid != CARLA_URI_MAP_ID_NULL,);
CARLA_SAFE_ASSERT_RETURN(uri != nullptr && uri[0] != '\0',); CARLA_SAFE_ASSERT_RETURN(uri != nullptr && uri[0] != '\0',);
carla_stdout("CarlaPluginLV2::handleUridMap(%i v " P_SIZE ", \"%s\")", urid, fCustomURIDs.count()-1, uri);
carla_debug("CarlaPluginLV2::handleUridMap(%i v " P_SIZE ", \"%s\")", urid, fCustomURIDs.count()-1, uri);


if (urid < fCustomURIDs.count()) if (urid < fCustomURIDs.count())
{ {


+ 15
- 3
source/bridges-ui/CarlaBridgeUI.cpp View File

@@ -32,6 +32,7 @@ CarlaBridgeUI::CarlaBridgeUI() noexcept
: CarlaPipeClient(), : CarlaPipeClient(),
fQuitReceived(false), fQuitReceived(false),
fGotOptions(false), fGotOptions(false),
fLastMsgTimer(-1),
fToolkit(nullptr), fToolkit(nullptr),
fLib(nullptr), fLib(nullptr),
fLibFilename(), fLibFilename(),
@@ -112,6 +113,9 @@ bool CarlaBridgeUI::msgReceived(const char* const msg) noexcept
CARLA_SAFE_ASSERT_RETURN(std::strcmp(msg, "urid") == 0 || std::strcmp(msg, "uiOptions") == 0, true); CARLA_SAFE_ASSERT_RETURN(std::strcmp(msg, "urid") == 0 || std::strcmp(msg, "uiOptions") == 0, true);
} }


if (fLastMsgTimer > 0)
--fLastMsgTimer;

if (std::strcmp(msg, "control") == 0) if (std::strcmp(msg, "control") == 0)
{ {
uint32_t index; uint32_t index;
@@ -284,15 +288,23 @@ bool CarlaBridgeUI::init(const int argc, const char* argv[])
if (! initPipeClient(argv)) if (! initPipeClient(argv))
return false; return false;


// wait for ui options, FIXME
for (int i=0; i<20 && ! fGotOptions; ++i)
fLastMsgTimer = 0;

// wait for ui options
for (; ++fLastMsgTimer < 50 && ! fGotOptions;)
{ {
idlePipe(true); idlePipe(true);
carla_msleep(100);
carla_msleep(20);
} }


if (! fGotOptions) if (! fGotOptions)
{ {
carla_stderr2("CarlaBridgeUI::init() - did not get options on time, quitting...");
{
const CarlaMutexLocker cml(getPipeLock());
writeMessage("exiting\n", 8);
flushMessages();
}
closePipeClient(); closePipeClient();
return false; return false;
} }


+ 1
- 0
source/bridges-ui/CarlaBridgeUI.hpp View File

@@ -142,6 +142,7 @@ public:
protected: protected:
bool fQuitReceived; bool fQuitReceived;
bool fGotOptions; bool fGotOptions;
int fLastMsgTimer;
CarlaBridgeToolkit* fToolkit; CarlaBridgeToolkit* fToolkit;


lib_t fLib; lib_t fLib;


Loading…
Cancel
Save