From a987e7331a6665d8b4853704ff94f514ef9b12a4 Mon Sep 17 00:00:00 2001 From: falkTX Date: Sat, 4 Jul 2015 21:25:48 +0200 Subject: [PATCH] carla-plugin: Return direct values --- source/plugin/carla-lv2.cpp | 42 +++++++------------------------------ source/plugin/carla-vst.cpp | 31 ++++++--------------------- 2 files changed, 14 insertions(+), 59 deletions(-) diff --git a/source/plugin/carla-lv2.cpp b/source/plugin/carla-lv2.cpp index 41bb67eba..aced99da8 100644 --- a/source/plugin/carla-lv2.cpp +++ b/source/plugin/carla-lv2.cpp @@ -83,7 +83,7 @@ public: fMidiEventCount(0), fTimeInfo(), fLastTimeSpeed(0.0), - fIsProcessing(false), + fIsOffline(false), fBufferSize(0), fSampleRate(sampleRate), fUridMap(nullptr), @@ -251,6 +251,8 @@ public: void lv2_run(const uint32_t frames) { + fIsOffline = (fPorts.freewheel != nullptr && *fPorts.freewheel >= 0.5f); + if (frames == 0) { updateParameterOutputs(); @@ -470,10 +472,8 @@ public: } } - fIsProcessing = true; // FIXME fDescriptor->process(fHandle, const_cast(fPorts.audioIns), fPorts.audioOuts, frames, fMidiEvents, fMidiEventCount); - fIsProcessing = false; // update timePos for next callback if (carla_isNotEqual(fLastTimeSpeed, 0.0)) @@ -877,33 +877,8 @@ protected: // ------------------------------------------------------------------- - uint32_t handleGetBufferSize() const - { - return fBufferSize; - } - - double handleGetSampleRate() const - { - return fSampleRate; - } - - bool handleIsOffline() const - { - CARLA_SAFE_ASSERT_RETURN(fIsProcessing, false); - - return (fPorts.freewheel != nullptr && *fPorts.freewheel >= 0.5f); - } - - const NativeTimeInfo* handleGetTimeInfo() const - { - CARLA_SAFE_ASSERT_RETURN(fIsProcessing, nullptr); - - return &fTimeInfo; - } - bool handleWriteMidiEvent(const NativeMidiEvent* const event) { - CARLA_SAFE_ASSERT_RETURN(fIsProcessing, false); CARLA_SAFE_ASSERT_RETURN(fDescriptor->midiOuts > 0, false); CARLA_SAFE_ASSERT_RETURN(event != nullptr, false); CARLA_SAFE_ASSERT_RETURN(event->data[0] != 0, false); @@ -1015,9 +990,8 @@ private: NativeTimeInfo fTimeInfo; double fLastTimeSpeed; - bool fIsProcessing; - // Lv2 host data + bool fIsOffline; uint32_t fBufferSize; double fSampleRate; @@ -1328,22 +1302,22 @@ private: static uint32_t host_get_buffer_size(NativeHostHandle handle) { - return handlePtr->handleGetBufferSize(); + return handlePtr->fBufferSize; } static double host_get_sample_rate(NativeHostHandle handle) { - return handlePtr->handleGetSampleRate(); + return handlePtr->fSampleRate; } static bool host_is_offline(NativeHostHandle handle) { - return handlePtr->handleIsOffline(); + return handlePtr->fIsOffline; } static const NativeTimeInfo* host_get_time_info(NativeHostHandle handle) { - return handlePtr->handleGetTimeInfo(); + return &(handlePtr->fTimeInfo); } static bool host_write_midi_event(NativeHostHandle handle, const NativeMidiEvent* event) diff --git a/source/plugin/carla-vst.cpp b/source/plugin/carla-vst.cpp index fc0fcb76f..a22a8c543 100644 --- a/source/plugin/carla-vst.cpp +++ b/source/plugin/carla-vst.cpp @@ -449,26 +449,6 @@ public: protected: // ------------------------------------------------------------------- - uint32_t handleGetBufferSize() const - { - return fBufferSize; - } - - double handleGetSampleRate() const - { - return fSampleRate; - } - - bool handleIsOffline() const - { - return false; - } - - const NativeTimeInfo* handleGetTimeInfo() const - { - return &fTimeInfo; - } - bool handleWriteMidiEvent(const NativeMidiEvent* const event) { CARLA_SAFE_ASSERT_RETURN(fDescriptor->midiOuts > 0, false); @@ -607,22 +587,23 @@ private: static uint32_t host_get_buffer_size(NativeHostHandle handle) { - return handlePtr->handleGetBufferSize(); + return handlePtr->fBufferSize; } static double host_get_sample_rate(NativeHostHandle handle) { - return handlePtr->handleGetSampleRate(); + return handlePtr->fSampleRate; } - static bool host_is_offline(NativeHostHandle handle) + static bool host_is_offline(NativeHostHandle /*handle*/) { - return handlePtr->handleIsOffline(); + // TODO + return false; } static const NativeTimeInfo* host_get_time_info(NativeHostHandle handle) { - return handlePtr->handleGetTimeInfo(); + return &(handlePtr->fTimeInfo); } static bool host_write_midi_event(NativeHostHandle handle, const NativeMidiEvent* event)