| @@ -367,7 +367,7 @@ struct EngineTimeInfo { | |||
| */ | |||
| class CarlaEnginePort | |||
| { | |||
| public: | |||
| protected: | |||
| /*! | |||
| * The constructor.\n | |||
| * Param \a isInput defines wherever this is an input port or not (output otherwise).\n | |||
| @@ -375,6 +375,7 @@ public: | |||
| */ | |||
| CarlaEnginePort(const CarlaEngine& engine, const bool isInput); | |||
| public: | |||
| /*! | |||
| * The destructor. | |||
| */ | |||
| @@ -435,7 +436,9 @@ public: | |||
| /*! | |||
| * Initialize the port's internal buffer. | |||
| */ | |||
| virtual void initBuffer() override; | |||
| virtual void initBuffer() override | |||
| { | |||
| } | |||
| /*! | |||
| * Direct access to the port's audio buffer. | |||
| @@ -552,7 +555,7 @@ public: | |||
| virtual const EngineEvent& getEvent(const uint32_t index); | |||
| /*! | |||
| * TODO. | |||
| * Get the event at \a index, faster unchecked version. | |||
| */ | |||
| virtual const EngineEvent& getEventUnchecked(const uint32_t index); | |||
| @@ -606,8 +609,8 @@ protected: | |||
| /*! | |||
| * Carla Engine client.\n | |||
| * Each plugin requires one client from the engine (created via CarlaEngine::addPort()).\n | |||
| * \note This is a virtual class, each engine type provides its own funtionality. | |||
| * Each plugin requires one client from the engine (created via CarlaEngine::addClient()).\n | |||
| * \note This is a virtual class, some engine types provide custom funtionality. | |||
| */ | |||
| class CarlaEngineClient | |||
| { | |||
| @@ -639,24 +642,24 @@ public: | |||
| /*! | |||
| * Check if the client is activated. | |||
| */ | |||
| virtual bool isActive() const; | |||
| virtual bool isActive() const noexcept; | |||
| /*! | |||
| * Check if the client is ok.\n | |||
| * Plugins will refuse to instantiate if this returns false. | |||
| * \note This is always true in rack and patchbay processing modes. | |||
| */ | |||
| virtual bool isOk() const; | |||
| virtual bool isOk() const noexcept; | |||
| /*! | |||
| * Get the current latency, in samples. | |||
| */ | |||
| virtual uint32_t getLatency() const; | |||
| virtual uint32_t getLatency() const noexcept; | |||
| /*! | |||
| * Change the client's latency. | |||
| */ | |||
| virtual void setLatency(const uint32_t samples); | |||
| virtual void setLatency(const uint32_t samples) noexcept; | |||
| /*! | |||
| * Add a new port of type \a portType. | |||
| @@ -735,12 +738,12 @@ public: | |||
| /*! | |||
| * Maximum client name size. | |||
| */ | |||
| virtual unsigned int getMaxClientNameSize() const; | |||
| virtual unsigned int getMaxClientNameSize() const noexcept; | |||
| /*! | |||
| * Maximum port name size. | |||
| */ | |||
| virtual unsigned int getMaxPortNameSize() const; | |||
| virtual unsigned int getMaxPortNameSize() const noexcept; | |||
| /*! | |||
| * Current number of plugins loaded. | |||
| @@ -1175,23 +1178,27 @@ private: | |||
| static CarlaEngine* newJack(); | |||
| #ifndef BUILD_BRIDGE | |||
| static CarlaEngine* newJuce(); | |||
| enum AudioApi { | |||
| AUDIO_API_NULL = 0, | |||
| // common | |||
| AUDIO_API_JACK = 1, | |||
| // linux | |||
| AUDIO_API_ALSA = 2, | |||
| AUDIO_API_OSS = 3, | |||
| AUDIO_API_PULSE = 4, | |||
| // macos | |||
| AUDIO_API_CORE = 5, | |||
| // windows | |||
| AUDIO_API_ASIO = 6, | |||
| AUDIO_API_DS = 7 | |||
| }; | |||
| static CarlaEngine* newJuce(const AudioApi api); | |||
| static size_t getJuceApiCount(); | |||
| static const char* getJuceApiName(const unsigned int index); | |||
| static const char** getJuceApiDeviceNames(const unsigned int index); | |||
| enum RtAudioApi { | |||
| RTAUDIO_DUMMY = 0, | |||
| RTAUDIO_LINUX_ALSA = 1, | |||
| RTAUDIO_LINUX_PULSE = 2, | |||
| RTAUDIO_LINUX_OSS = 3, | |||
| RTAUDIO_UNIX_JACK = 4, | |||
| RTAUDIO_MACOSX_CORE = 5, | |||
| RTAUDIO_WINDOWS_ASIO = 6, | |||
| RTAUDIO_WINDOWS_DS = 7 | |||
| }; | |||
| static CarlaEngine* newRtAudio(const RtAudioApi api); | |||
| static CarlaEngine* newRtAudio(const AudioApi api); | |||
| static size_t getRtAudioApiCount(); | |||
| static const char* getRtAudioApiName(const unsigned int index); | |||
| static const char** getRtAudioApiDeviceNames(const unsigned int index); | |||
| @@ -65,10 +65,6 @@ CarlaEngineAudioPort::~CarlaEngineAudioPort() | |||
| carla_debug("CarlaEngineAudioPort::~CarlaEngineAudioPort()"); | |||
| } | |||
| void CarlaEngineAudioPort::initBuffer() | |||
| { | |||
| } | |||
| // ----------------------------------------------------------------------- | |||
| // Carla Engine CV port | |||
| @@ -195,13 +191,15 @@ void CarlaEngineEventPort::writeControlEvent(const uint32_t time, const uint8_t | |||
| if (fBuffer[i].type != kEngineEventTypeNull) | |||
| continue; | |||
| fBuffer[i].type = kEngineEventTypeControl; | |||
| fBuffer[i].time = time; | |||
| fBuffer[i].channel = channel; | |||
| EngineEvent& event(fBuffer[i]); | |||
| fBuffer[i].ctrl.type = type; | |||
| fBuffer[i].ctrl.param = param; | |||
| fBuffer[i].ctrl.value = fixedValue; | |||
| event.type = kEngineEventTypeControl; | |||
| event.time = time; | |||
| event.channel = channel; | |||
| event.ctrl.type = type; | |||
| event.ctrl.param = param; | |||
| event.ctrl.value = fixedValue; | |||
| return; | |||
| } | |||
| @@ -223,17 +221,19 @@ void CarlaEngineEventPort::writeMidiEvent(const uint32_t time, const uint8_t cha | |||
| if (fBuffer[i].type != kEngineEventTypeNull) | |||
| continue; | |||
| fBuffer[i].type = kEngineEventTypeMidi; | |||
| fBuffer[i].time = time; | |||
| fBuffer[i].channel = channel; | |||
| EngineEvent& event(fBuffer[i]); | |||
| event.type = kEngineEventTypeMidi; | |||
| event.time = time; | |||
| event.channel = channel; | |||
| fBuffer[i].midi.port = port; | |||
| fBuffer[i].midi.size = size; | |||
| event.midi.port = port; | |||
| event.midi.size = size; | |||
| fBuffer[i].midi.data[0] = MIDI_GET_CHANNEL_FROM_DATA(data); | |||
| event.midi.data[0] = MIDI_GET_CHANNEL_FROM_DATA(data); | |||
| for (uint8_t j=1; j < size; ++j) | |||
| fBuffer[i].midi.data[j] = data[j]; | |||
| event.midi.data[j] = data[j]; | |||
| return; | |||
| } | |||
| @@ -274,33 +274,30 @@ void CarlaEngineClient::deactivate() | |||
| fActive = false; | |||
| } | |||
| bool CarlaEngineClient::isActive() const | |||
| bool CarlaEngineClient::isActive() const noexcept | |||
| { | |||
| carla_debug("CarlaEngineClient::isActive()"); | |||
| return fActive; | |||
| } | |||
| bool CarlaEngineClient::isOk() const | |||
| bool CarlaEngineClient::isOk() const noexcept | |||
| { | |||
| carla_debug("CarlaEngineClient::isOk()"); | |||
| return true; | |||
| } | |||
| uint32_t CarlaEngineClient::getLatency() const | |||
| uint32_t CarlaEngineClient::getLatency() const noexcept | |||
| { | |||
| return fLatency; | |||
| } | |||
| void CarlaEngineClient::setLatency(const uint32_t samples) | |||
| void CarlaEngineClient::setLatency(const uint32_t samples) noexcept | |||
| { | |||
| fLatency = samples; | |||
| } | |||
| CarlaEnginePort* CarlaEngineClient::addPort(const EnginePortType portType, const char* const name, const bool isInput) | |||
| { | |||
| carla_debug("CarlaEngineClient::addPort(%s, \"%s\", %s)", EnginePortType2Str(portType), name, bool2str(isInput)); | |||
| CARLA_SAFE_ASSERT_RETURN(name != nullptr && name[0] != '\0', nullptr); | |||
| carla_debug("CarlaEngineClient::addPort(%i:%s, \"%s\", %s)", portType, EnginePortType2Str(portType), name, bool2str(isInput)); | |||
| switch (portType) | |||
| { | |||
| @@ -339,7 +336,7 @@ CarlaEngine::~CarlaEngine() | |||
| } | |||
| // ----------------------------------------------------------------------- | |||
| // Static values and calls | |||
| // Static calls | |||
| unsigned int CarlaEngine::getDriverCount() | |||
| { | |||
| @@ -384,9 +381,7 @@ const char** CarlaEngine::getDriverDeviceNames(const unsigned int index) | |||
| if (index == 0) | |||
| { | |||
| //static const char* const strOff = "Auto-connect OFF"; | |||
| //static const char* const strOn = "Auto-connect ON"; | |||
| static const char* ret[3] = { "Auto-connect OFF", "Auto-connect ON", nullptr }; | |||
| static const char* ret[3] = { "Auto-Connect OFF", "Auto-Connect ON", nullptr }; | |||
| return ret; | |||
| } | |||
| @@ -408,39 +403,33 @@ const char** CarlaEngine::getDriverDeviceNames(const unsigned int index) | |||
| CarlaEngine* CarlaEngine::newDriverByName(const char* const driverName) | |||
| { | |||
| CARLA_SAFE_ASSERT_RETURN(driverName != nullptr && driverName[0] != '\0', nullptr); | |||
| carla_debug("CarlaEngine::newDriverByName(\"%s\")", driverName); | |||
| if (std::strcmp(driverName, "JACK") == 0) | |||
| return newJack(); | |||
| #ifdef __LINUX_ALSA__ | |||
| // common | |||
| if (std::strncmp(driverName, "JACK ", 5) == 0) | |||
| return newRtAudio(AUDIO_API_JACK); | |||
| // linux | |||
| if (std::strcmp(driverName, "ALSA") == 0) | |||
| return newRtAudio(RTAUDIO_LINUX_ALSA); | |||
| #endif | |||
| #ifdef __LINUX_PULSE__ | |||
| if (std::strcmp(driverName, "PulseAudio") == 0) | |||
| return newRtAudio(RTAUDIO_LINUX_PULSE); | |||
| #endif | |||
| #ifdef __LINUX_OSS__ | |||
| return newRtAudio(AUDIO_API_ALSA); | |||
| if (std::strcmp(driverName, "OSS") == 0) | |||
| return newRtAudio(RTAUDIO_LINUX_OSS); | |||
| #endif | |||
| #ifdef __UNIX_JACK__ | |||
| if (std::strncmp(driverName, "JACK ", 5) == 0) | |||
| return newRtAudio(RTAUDIO_UNIX_JACK); | |||
| #endif | |||
| #ifdef __MACOSX_CORE__ | |||
| return newRtAudio(AUDIO_API_OSS); | |||
| if (std::strcmp(driverName, "PulseAudio") == 0) | |||
| return newRtAudio(AUDIO_API_PULSE); | |||
| // macos | |||
| if (std::strcmp(driverName, "CoreAudio") == 0) | |||
| return newRtAudio(RTAUDIO_MACOSX_CORE); | |||
| #endif | |||
| #ifdef __WINDOWS_ASIO__ | |||
| return newRtAudio(AUDIO_API_CORE); | |||
| // windows | |||
| if (std::strcmp(driverName, "ASIO") == 0) | |||
| return newRtAudio(RTAUDIO_WINDOWS_ASIO); | |||
| #endif | |||
| #ifdef __WINDOWS_DS__ | |||
| return newRtAudio(AUDIO_API_ASIO); | |||
| if (std::strcmp(driverName, "DirectSound") == 0) | |||
| return newRtAudio(RTAUDIO_WINDOWS_DS); | |||
| #endif | |||
| return newRtAudio(AUDIO_API_DS); | |||
| carla_stderr("CarlaEngine::newDriverByName(\"%s\") - invalid driver name", driverName); | |||
| return nullptr; | |||
| @@ -449,12 +438,12 @@ CarlaEngine* CarlaEngine::newDriverByName(const char* const driverName) | |||
| // ----------------------------------------------------------------------- | |||
| // Maximum values | |||
| unsigned int CarlaEngine::getMaxClientNameSize() const | |||
| unsigned int CarlaEngine::getMaxClientNameSize() const noexcept | |||
| { | |||
| return STR_MAX/2; | |||
| } | |||
| unsigned int CarlaEngine::getMaxPortNameSize() const | |||
| unsigned int CarlaEngine::getMaxPortNameSize() const noexcept | |||
| { | |||
| return STR_MAX; | |||
| } | |||
| @@ -474,6 +463,7 @@ unsigned int CarlaEngine::getMaxPluginNumber() const noexcept | |||
| bool CarlaEngine::init(const char* const clientName) | |||
| { | |||
| CARLA_SAFE_ASSERT_RETURN(clientName != nullptr && clientName[0] != '\0', false); | |||
| CARLA_ASSERT(fName.isEmpty()); | |||
| CARLA_ASSERT(pData->oscData == nullptr); | |||
| CARLA_ASSERT(pData->plugins == nullptr); | |||
| @@ -465,10 +465,8 @@ public: | |||
| CarlaEngineClient::deactivate(); | |||
| } | |||
| bool isOk() const override | |||
| bool isOk() const noexcept override | |||
| { | |||
| carla_debug("CarlaEngineJackClient::isOk()"); | |||
| if (fUseClient) | |||
| return (fClient != nullptr); | |||
| @@ -476,12 +474,15 @@ public: | |||
| } | |||
| #if 0 | |||
| void setLatency(const uint32_t samples) override | |||
| void setLatency(const uint32_t samples) noexcept override | |||
| { | |||
| CarlaEngineClient::setLatency(samples); | |||
| if (fUseClient && fClient != nullptr) | |||
| { | |||
| // try etc | |||
| jackbridge_recompute_total_latencies(fClient); | |||
| } | |||
| } | |||
| #endif | |||
| @@ -592,7 +593,16 @@ public: | |||
| unsigned int getMaxClientNameSize() const noexcept override | |||
| { | |||
| if (fOptions.processMode == PROCESS_MODE_SINGLE_CLIENT || fOptions.processMode == PROCESS_MODE_MULTIPLE_CLIENTS) | |||
| return static_cast<unsigned int>(jackbridge_client_name_size()); | |||
| { | |||
| unsigned int ret = 0; | |||
| try { | |||
| ret = static_cast<unsigned int>(jackbridge_client_name_size()); | |||
| } | |||
| catch (...) {} | |||
| return ret; | |||
| } | |||
| return CarlaEngine::getMaxClientNameSize(); | |||
| } | |||
| @@ -600,7 +610,16 @@ public: | |||
| unsigned int getMaxPortNameSize() const noexcept override | |||
| { | |||
| if (fOptions.processMode == PROCESS_MODE_SINGLE_CLIENT || fOptions.processMode == PROCESS_MODE_MULTIPLE_CLIENTS) | |||
| return static_cast<unsigned int>(jackbridge_port_name_size()); | |||
| { | |||
| unsigned int ret = 0; | |||
| try { | |||
| ret = static_cast<unsigned int>(jackbridge_port_name_size()); | |||
| } | |||
| catch (...) {} | |||
| return ret; | |||
| } | |||
| return CarlaEngine::getMaxPortNameSize(); | |||
| } | |||
| @@ -117,7 +117,7 @@ private: | |||
| // ----------------------------------------- | |||
| CarlaEngine* CarlaEngine::newJuce() | |||
| CarlaEngine* CarlaEngine::newJuce(const AudioApi /*api*/) | |||
| { | |||
| return new CarlaEngineJuce(); | |||
| } | |||
| @@ -127,12 +127,12 @@ size_t CarlaEngine::getJuceApiCount() | |||
| return 0; | |||
| } | |||
| const char* CarlaEngine::getJuceApiName(const unsigned int index) | |||
| const char* CarlaEngine::getJuceApiName(const unsigned int /*index*/) | |||
| { | |||
| return nullptr; | |||
| } | |||
| const char** CarlaEngine::getJuceApiDeviceNames(const unsigned int index) | |||
| const char** CarlaEngine::getJuceApiDeviceNames(const unsigned int /*index*/) | |||
| { | |||
| #if 0 | |||
| juce::ScopedPointer<juce::AudioIODeviceType> deviceType; | |||
| @@ -1328,34 +1328,34 @@ private: | |||
| // ----------------------------------------- | |||
| CarlaEngine* CarlaEngine::newRtAudio(RtAudioApi api) | |||
| CarlaEngine* CarlaEngine::newRtAudio(AudioApi api) | |||
| { | |||
| RtAudio::Api rtApi(RtAudio::UNSPECIFIED); | |||
| switch (api) | |||
| { | |||
| case RTAUDIO_DUMMY: | |||
| case AUDIO_API_NULL: | |||
| rtApi = RtAudio::RTAUDIO_DUMMY; | |||
| break; | |||
| case RTAUDIO_LINUX_ALSA: | |||
| rtApi = RtAudio::LINUX_ALSA; | |||
| case AUDIO_API_JACK: | |||
| rtApi = RtAudio::UNIX_JACK; | |||
| break; | |||
| case RTAUDIO_LINUX_PULSE: | |||
| rtApi = RtAudio::LINUX_PULSE; | |||
| case AUDIO_API_ALSA: | |||
| rtApi = RtAudio::LINUX_ALSA; | |||
| break; | |||
| case RTAUDIO_LINUX_OSS: | |||
| case AUDIO_API_OSS: | |||
| rtApi = RtAudio::LINUX_OSS; | |||
| break; | |||
| case RTAUDIO_UNIX_JACK: | |||
| rtApi = RtAudio::UNIX_JACK; | |||
| case AUDIO_API_PULSE: | |||
| rtApi = RtAudio::LINUX_PULSE; | |||
| break; | |||
| case RTAUDIO_MACOSX_CORE: | |||
| case AUDIO_API_CORE: | |||
| rtApi = RtAudio::MACOSX_CORE; | |||
| break; | |||
| case RTAUDIO_WINDOWS_ASIO: | |||
| case AUDIO_API_ASIO: | |||
| rtApi = RtAudio::WINDOWS_ASIO; | |||
| break; | |||
| case RTAUDIO_WINDOWS_DS: | |||
| case AUDIO_API_DS: | |||
| rtApi = RtAudio::WINDOWS_DS; | |||
| break; | |||
| } | |||