From b977a0907a35792617ba6f37c8866cb0589806fe Mon Sep 17 00:00:00 2001 From: falkTX Date: Sun, 17 Feb 2013 19:58:33 +0000 Subject: [PATCH] Fixes for gcc4.4 compatibility, misc changes --- source/backend/CarlaEngine.hpp | 4 + .../backend/engine/rtaudio-4.0.11/RtAudio.h | 2 + source/backend/engine/rtmidi-2.0.1/RtMidi.h | 2 + source/discovery/carla-discovery.cpp | 201 +++++++++--------- source/includes/CarlaDefines.hpp | 9 +- source/utils/CarlaStateUtils.hpp | 1 + 6 files changed, 119 insertions(+), 100 deletions(-) diff --git a/source/backend/CarlaEngine.hpp b/source/backend/CarlaEngine.hpp index 908f8e09e..4db1ac07a 100644 --- a/source/backend/CarlaEngine.hpp +++ b/source/backend/CarlaEngine.hpp @@ -149,10 +149,12 @@ struct EngineControlEvent { uint16_t param; //!< Parameter ID, midi bank or midi program. double value; //!< Parameter value, normalized to 0.0<->1.0. +#ifndef CARLA_PROPER_CPP11_SUPPORT EngineControlEvent() { clear(); } +#endif void clear() { @@ -170,10 +172,12 @@ struct EngineMidiEvent { uint8_t data[3]; //!< MIDI data, without channel bit uint8_t size; //!< Number of bytes used +#ifndef CARLA_PROPER_CPP11_SUPPORT EngineMidiEvent() { clear(); } +#endif void clear() { diff --git a/source/backend/engine/rtaudio-4.0.11/RtAudio.h b/source/backend/engine/rtaudio-4.0.11/RtAudio.h index cf8a2d518..44391e3eb 100644 --- a/source/backend/engine/rtaudio-4.0.11/RtAudio.h +++ b/source/backend/engine/rtaudio-4.0.11/RtAudio.h @@ -47,6 +47,8 @@ #ifndef __RTAUDIO_H #define __RTAUDIO_H +#include "CarlaDefines.hpp" + #include #include #include "RtError.h" diff --git a/source/backend/engine/rtmidi-2.0.1/RtMidi.h b/source/backend/engine/rtmidi-2.0.1/RtMidi.h index 6f3cbf1a6..350f0c187 100644 --- a/source/backend/engine/rtmidi-2.0.1/RtMidi.h +++ b/source/backend/engine/rtmidi-2.0.1/RtMidi.h @@ -45,6 +45,8 @@ #ifndef RTMIDI_H #define RTMIDI_H +#include "CarlaDefines.hpp" + #include "RtError.h" #include #include diff --git a/source/discovery/carla-discovery.cpp b/source/discovery/carla-discovery.cpp index 35e6ce5f1..764dfe9cc 100644 --- a/source/discovery/carla-discovery.cpp +++ b/source/discovery/carla-discovery.cpp @@ -15,25 +15,25 @@ * For a full copy of the GNU General Public License see the GPL.txt file */ -#include "carla_backend.hpp" -#include "carla_juce_utils.hpp" -#include "carla_lib_utils.hpp" -#include "carla_midi.h" +#include "CarlaBackend.hpp" +#include "CarlaJuceUtils.hpp" +#include "CarlaLibUtils.hpp" +#include "CarlaMIDI.h" #ifdef WANT_LADSPA -# include "carla_ladspa_utils.hpp" +# include "CarlaLadspaUtils.hpp" #endif #ifdef WANT_DSSI -# include "carla_ladspa_utils.hpp" +# include "CarlaLadspaUtils.hpp" # include "dssi/dssi.h" #endif #ifdef WANT_LV2 # include # include -# include "carla_lv2_utils.hpp" +# include "CarlaLv2Utils.hpp" #endif #ifdef WANT_VST -# include "carla_vst_utils.hpp" +# include "CarlaVstUtils.hpp" #endif #ifdef WANT_FLUIDSYNTH # include @@ -257,6 +257,101 @@ intptr_t VSTCALLBACK vstHostCallback(AEffect* const effect, const int32_t opcode } #endif +// -------------------------------------------------------------------------- +// LinuxSampler stuff + +#ifdef WANT_LINUXSAMPLER +class LinuxSamplerScopedEngine +{ +public: + LinuxSamplerScopedEngine(const char* const filename, const char* const stype) + : engine(nullptr), + ins(nullptr) + { + using namespace LinuxSampler; + + try { + engine = EngineFactory::Create(stype); + } + catch (const Exception& e) + { + DISCOVERY_OUT("error", e.what()); + return; + } + + if (engine == nullptr) + return; + + ins = engine->GetInstrumentManager(); + + if (ins == nullptr) + { + DISCOVERY_OUT("error", "Failed to get LinuxSampler instrument manager"); + return; + } + + std::vector ids; + + try { + ids = ins->GetInstrumentFileContent(filename); + } + catch (const Exception& e) + { + DISCOVERY_OUT("error", e.what()); + return; + } + + if (ids.size() > 0) + { + InstrumentManager::instrument_info_t info = ins->GetInstrumentInfo(ids[0]); + outputInfo(&info, ids.size()); + } + } + + ~LinuxSamplerScopedEngine() + { + if (engine != nullptr) + EngineFactory::Destroy(engine); + } + + static void outputInfo(InstrumentManager::instrument_info_t* const info, const int programs, const char* const basename = nullptr) + { + DISCOVERY_OUT("init", "-----------"); + + if (info) + { + DISCOVERY_OUT("name", info->InstrumentName); + DISCOVERY_OUT("label", info->Product); + DISCOVERY_OUT("maker", info->Artists); + DISCOVERY_OUT("copyright", info->Artists); + } + else + { + DISCOVERY_OUT("name", basename); + DISCOVERY_OUT("label", basename); + } + + DISCOVERY_OUT("hints", PLUGIN_IS_SYNTH); + DISCOVERY_OUT("audio.outs", 2); + DISCOVERY_OUT("audio.total", 2); + DISCOVERY_OUT("midi.ins", 1); + DISCOVERY_OUT("midi.total", 1); + DISCOVERY_OUT("programs.total", programs); + //DISCOVERY_OUT("parameters.ins", 13); // defined in Carla - TODO + //DISCOVERY_OUT("parameters.outs", 1); + //DISCOVERY_OUT("parameters.total", 14); + DISCOVERY_OUT("build", BINARY_NATIVE); + DISCOVERY_OUT("end", "------------"); + } + +private: + Engine* engine; + InstrumentManager* ins; + + CARLA_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(LinuxSamplerScopedEngine) +}; +#endif + // ------------------------------ Plugin Checks ----------------------------- void do_ladspa_check(void* const libHandle, const bool init) @@ -1241,96 +1336,6 @@ void do_linuxsampler_check(const char* const filename, const char* const stype, return; } - using namespace LinuxSampler; - - class LinuxSamplerScopedEngine - { - public: - LinuxSamplerScopedEngine(const char* const filename, const char* const stype) - { - engine = nullptr; - - try { - engine = EngineFactory::Create(stype); - } - catch (const Exception& e) - { - DISCOVERY_OUT("error", e.what()); - return; - } - - if (! engine) - return; - - ins = engine->GetInstrumentManager(); - - if (! ins) - { - DISCOVERY_OUT("error", "Failed to get LinuxSampler instrument manager"); - return; - } - - std::vector ids; - - try { - ids = ins->GetInstrumentFileContent(filename); - } - catch (const Exception& e) - { - DISCOVERY_OUT("error", e.what()); - return; - } - - if (ids.size() > 0) - { - InstrumentManager::instrument_info_t info = ins->GetInstrumentInfo(ids[0]); - outputInfo(&info, ids.size()); - } - } - - ~LinuxSamplerScopedEngine() - { - if (engine) - EngineFactory::Destroy(engine); - } - - static void outputInfo(InstrumentManager::instrument_info_t* const info, const int programs, const char* const basename = nullptr) - { - DISCOVERY_OUT("init", "-----------"); - - if (info) - { - DISCOVERY_OUT("name", info->InstrumentName); - DISCOVERY_OUT("label", info->Product); - DISCOVERY_OUT("maker", info->Artists); - DISCOVERY_OUT("copyright", info->Artists); - } - else - { - DISCOVERY_OUT("name", basename); - DISCOVERY_OUT("label", basename); - } - - DISCOVERY_OUT("hints", PLUGIN_IS_SYNTH); - DISCOVERY_OUT("audio.outs", 2); - DISCOVERY_OUT("audio.total", 2); - DISCOVERY_OUT("midi.ins", 1); - DISCOVERY_OUT("midi.total", 1); - DISCOVERY_OUT("programs.total", programs); - //DISCOVERY_OUT("parameters.ins", 13); // defined in Carla - TODO - //DISCOVERY_OUT("parameters.outs", 1); - //DISCOVERY_OUT("parameters.total", 14); - DISCOVERY_OUT("build", BINARY_NATIVE); - DISCOVERY_OUT("end", "------------"); - } - - private: - Engine* engine; - InstrumentManager* ins; - - CARLA_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(LinuxSamplerScopedEngine) - }; - if (init) const LinuxSamplerScopedEngine engine(filename, stype); else diff --git a/source/includes/CarlaDefines.hpp b/source/includes/CarlaDefines.hpp index 0beb226bd..56550324f 100644 --- a/source/includes/CarlaDefines.hpp +++ b/source/includes/CarlaDefines.hpp @@ -41,13 +41,18 @@ // Check for C++11 support #if defined(HAVE_CPP11_SUPPORT) || defined(QTCREATOR_TEST) -# define CARLA_CPP11_SUPPORT +# define CARLA_PROPER_CPP11_SUPPORT #elif defined(__GNUC__) && defined(__GXX_EXPERIMENTAL_CXX0X__) # if (__GNUC__ * 100 + __GNUC_MINOR__) >= 405 -# define CARLA_CPP11_SUPPORT +# define CARLA_PROPER_CPP11_SUPPORT # endif #endif +#ifndef CARLA_PROPER_CPP11_SUPPORT +# define noexcept +# define nullptr (0) +#endif + // Common includes #ifdef CARLA_OS_WIN # include diff --git a/source/utils/CarlaStateUtils.hpp b/source/utils/CarlaStateUtils.hpp index 517fb6f8e..9a4146eb8 100644 --- a/source/utils/CarlaStateUtils.hpp +++ b/source/utils/CarlaStateUtils.hpp @@ -22,6 +22,7 @@ #include "CarlaUtils.hpp" #include +#include CARLA_BACKEND_START_NAMESPACE