Browse Source

Run OS main loop if using plugin bridge

tags/1.9.8
falkTX 7 years ago
parent
commit
980bcf992a
2 changed files with 56 additions and 2 deletions
  1. +4
    -2
      source/bridges-plugin/CarlaBridgePlugin.cpp
  2. +52
    -0
      source/utils/CarlaMainLoop.hpp

+ 4
- 2
source/bridges-plugin/CarlaBridgePlugin.cpp View File

@@ -19,6 +19,7 @@
#include "CarlaHost.h"

#include "CarlaBackendUtils.hpp"
#include "CarlaMainLoop.hpp"
#include "CarlaMIDI.h"

#ifdef CARLA_OS_UNIX
@@ -41,6 +42,7 @@
using CarlaBackend::CarlaEngine;
using CarlaBackend::EngineCallbackOpcode;
using CarlaBackend::EngineCallbackOpcode2Str;
using CarlaBackend::runMainLoopOnce;

using juce::CharPointer_UTF8;
using juce::File;
@@ -173,10 +175,10 @@ public:

gIsInitiated = true;

for (; ! gCloseNow;)
for (; runMainLoopOnce() && ! gCloseNow;)
{
gIdle();
carla_msleep(8);
carla_msleep(1);
}

carla_set_engine_about_to_close();


+ 52
- 0
source/utils/CarlaMainLoop.hpp View File

@@ -0,0 +1,52 @@
/*
* Carla DSSI utils
* Copyright (C) 2017 Filipe Coelho <falktx@falktx.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* For a full copy of the GNU General Public License see the doc/GPL.txt file.
*/

#ifndef CARLA_MAIN_LOOP_HPP_INCLUDED
#define CARLA_MAIN_LOOP_HPP_INCLUDED

#include "CarlaBackend.h"
#include "CarlaUtils.hpp"

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

CARLA_BACKEND_START_NAMESPACE

bool runMainLoopOnce()
{
#if defined(CARLA_OS_WIN)
MSG msg;
if (! ::PeekMessage(&msg, nullptr, 0, 0, PM_NOREMOVE))
return true;

if (::GetMessage(&msg, nullptr, 0, 0) >= 0)
{
if (msg.message == WM_QUIT)
return false;

//TranslateMessage(&msg);
DispatchMessage(&msg);
}
#endif

return true;
}

CARLA_BACKEND_END_NAMESPACE

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

#endif // CARLA_MAIN_LOOP_HPP_INCLUDED

Loading…
Cancel
Save