diff --git a/source/backend/plugin/CarlaPluginNative.cpp b/source/backend/plugin/CarlaPluginNative.cpp index 9b94af0bf..09bc1ac67 100644 --- a/source/backend/plugin/CarlaPluginNative.cpp +++ b/source/backend/plugin/CarlaPluginNative.cpp @@ -252,7 +252,7 @@ public: fHost(), fDescriptor(nullptr), fIsProcessing(false), - fIsOffline(false), + fIsOffline(engine->isOffline()), fIsUiAvailable(false), fIsUiVisible(false), fNeedsIdle(false), diff --git a/source/native-plugins/audio-base.hpp b/source/native-plugins/audio-base.hpp index 815361641..954f04d1c 100644 --- a/source/native-plugins/audio-base.hpp +++ b/source/native-plugins/audio-base.hpp @@ -380,7 +380,12 @@ public: carla_copyFloats(pool.buffer[1], fPool.buffer[1], fPool.numFrames); } - bool tryPutData(float* const out1, float* const out2, uint64_t framePos, const uint32_t frames, bool& needsRead) + bool tryPutData(float* const out1, + float* const out2, + uint64_t framePos, + const uint32_t frames, + const bool isOffline, + bool& needsRead) { CARLA_SAFE_ASSERT_RETURN(fPool.numFrames != 0, false); @@ -436,7 +441,7 @@ public: if (frameDiff > numFramesNearEnd) { needsRead = true; - setNeedsRead(framePos + frames); + setNeedsRead(framePos + (isOffline ? 0 : frames)); } return true; @@ -477,7 +482,7 @@ public: fResampler.inp_data = buffer; fResampler.out_data = rbuffer; fResampler.process(); - CARLA_ASSERT_INT(fResampler.inp_count <= 1, fResampler.inp_count); + CARLA_SAFE_ASSERT_INT(fResampler.inp_count <= 1, fResampler.inp_count); } else { diff --git a/source/native-plugins/audio-file.cpp b/source/native-plugins/audio-file.cpp index 6b9acf269..a4bae9374 100644 --- a/source/native-plugins/audio-file.cpp +++ b/source/native-plugins/audio-file.cpp @@ -334,13 +334,33 @@ protected: } else { - if (! fReader.tryPutData(out1, out2, timePos->frame, frames, needsIdleRequest)) + const bool offline = isOffline(); + + if (! fReader.tryPutData(out1, out2, timePos->frame, frames, offline, needsIdleRequest)) { carla_zeroFloats(out1, frames); carla_zeroFloats(out2, frames); } + if (needsIdleRequest) + { fNeedsFileRead = true; + + if (isOffline()) + { + needsIdleRequest = false; + fReader.readPoll(); + + if (! fReader.tryPutData(out1, out2, timePos->frame, frames, offline, needsIdleRequest)) + { + carla_zeroFloats(out1, frames); + carla_zeroFloats(out2, frames); + } + + if (needsIdleRequest) + fNeedsFileRead = true; + } + } } #ifndef __MOD_DEVICES__ @@ -391,7 +411,10 @@ protected: NativePluginWithMidiPrograms::idle(); if (fNeedsFileRead) + { fReader.readPoll(); + fNeedsFileRead = false; + } #ifndef __MOD_DEVICES__ if (fInlineDisplay.pending == InlineDisplayNeedRequest) @@ -520,7 +543,7 @@ private: bool fLoopMode; bool fDoProcess; bool fWasPlayingBefore; - bool fNeedsFileRead; + volatile bool fNeedsFileRead; uint32_t fMaxFrame;