Browse Source

AudioFile and carla_copyDouble/Float optimizations

tags/1.9.4
falkTX 11 years ago
parent
commit
63d26bd474
3 changed files with 35 additions and 16 deletions
  1. +10
    -4
      source/backend/native/audio-base.hpp
  2. +9
    -4
      source/backend/native/audio-file.cpp
  3. +16
    -8
      source/utils/CarlaUtils.hpp

+ 10
- 4
source/backend/native/audio-base.hpp View File

@@ -148,6 +148,9 @@ public:

if (isRunning() && ! wait(1000))
terminate();

const CarlaMutex::ScopedLocker sl(&fMutex);
fPool.reset();
}

uint32_t getMaxFrame() const
@@ -212,9 +215,12 @@ public:
if (! fMutex.tryLock())
return;

pool.startFrame = fPool.startFrame;
carla_copyFloat(pool.buffer[0], fPool.buffer[0], fPool.size);
carla_copyFloat(pool.buffer[1], fPool.buffer[1], fPool.size);
//if (pool.startFrame != fPool.startFrame || pool.buffer[0] != fPool.buffer[0] || pool.buffer[1] != fPool.buffer[1])
{
pool.startFrame = fPool.startFrame;
carla_copyFloat(pool.buffer[0], fPool.buffer[0], fPool.size);
carla_copyFloat(pool.buffer[1], fPool.buffer[1], fPool.size);
}

fMutex.unlock();
}
@@ -349,7 +355,7 @@ protected:
{
const uint32_t lastFrame(kPlayer->getLastFrame());

if (fNeedsRead || lastFrame < fPool.startFrame || lastFrame - fPool.startFrame >= fPool.size*3/4)
if (fNeedsRead || lastFrame < fPool.startFrame || (lastFrame - fPool.startFrame >= fPool.size*3/4 && lastFrame < fFileNfo.frames))
readPoll();
else
carla_msleep(50);


+ 9
- 4
source/backend/native/audio-file.cpp View File

@@ -212,7 +212,8 @@ protected:
//carla_stderr("P: out of reach");
fLastFrame = timePos->frame;

fThread.setNeedsRead();
if (timePos->frame + frames < fPool.startFrame)
fThread.setNeedsRead();

carla_zeroFloat(out1, frames);
carla_zeroFloat(out2, frames);
@@ -287,11 +288,15 @@ private:
CARLA_ASSERT(filename != nullptr);
carla_debug("AudioFilePlugin::loadFilename(\"%s\")", filename);

if (filename == nullptr)
return;

fThread.stopNow();

if (filename == nullptr || *filename == '\0')
{
fDoProcess = false;
fMaxFrame = 0;
return;
}

if (fThread.loadFilename(filename))
{
fThread.startNow();


+ 16
- 8
source/utils/CarlaUtils.hpp View File

@@ -260,7 +260,7 @@ void carla_add(T* dataDst, T* dataSrc, const size_t size)
{
CARLA_ASSERT(dataDst != nullptr);
CARLA_ASSERT(dataSrc != nullptr);
CARLA_ASSERT(size > 0);
CARLA_ASSERT(size != 0);

if (dataDst == nullptr || dataSrc == nullptr || size == 0)
return;
@@ -275,7 +275,7 @@ void carla_add(T* dataDst, const T* dataSrc, const size_t size)
{
CARLA_ASSERT(dataDst != nullptr);
CARLA_ASSERT(dataSrc != nullptr);
CARLA_ASSERT(size > 0);
CARLA_ASSERT(size != 0);

if (dataDst == nullptr || dataSrc == nullptr || size == 0)
return;
@@ -290,7 +290,7 @@ void carla_copy(T* dataDst, T* dataSrc, const size_t size)
{
CARLA_ASSERT(dataDst != nullptr);
CARLA_ASSERT(dataSrc != nullptr);
CARLA_ASSERT(size > 0);
CARLA_ASSERT(size != 0);

if (dataDst == nullptr || dataSrc == nullptr || size == 0)
return;
@@ -305,7 +305,7 @@ void carla_copy(T* dataDst, const T* dataSrc, const size_t size)
{
CARLA_ASSERT(dataDst != nullptr);
CARLA_ASSERT(dataSrc != nullptr);
CARLA_ASSERT(size > 0);
CARLA_ASSERT(size != 0);

if (dataDst == nullptr || dataSrc == nullptr || size == 0)
return;
@@ -319,7 +319,7 @@ static inline
void carla_fill(T* data, const size_t size, const T v)
{
CARLA_ASSERT(data != nullptr);
CARLA_ASSERT(size > 0);
CARLA_ASSERT(size != 0);

if (data == nullptr || size == 0)
return;
@@ -343,13 +343,21 @@ void carla_addFloat(float* const dataDst, float* const dataSrc, const size_t siz
static inline
void carla_copyDouble(double* const dataDst, double* const dataSrc, const size_t size)
{
carla_copy<double>(dataDst, dataSrc, size);
CARLA_ASSERT(dataDst != nullptr);
CARLA_ASSERT(dataSrc != nullptr);
CARLA_ASSERT(size > 0);

std::memcpy(dataDst, dataSrc, size*sizeof(double));
}

static inline
void carla_copyFloat(float* const dataDst, float* const dataSrc, const size_t size)
{
carla_copy<float>(dataDst, dataSrc, size);
CARLA_ASSERT(dataDst != nullptr);
CARLA_ASSERT(dataSrc != nullptr);
CARLA_ASSERT(size > 0);

std::memcpy(dataDst, dataSrc, size*sizeof(float));
}

static inline
@@ -385,7 +393,7 @@ static inline
void carla_zeroMem(void* const memory, const size_t numBytes)
{
CARLA_ASSERT(memory != nullptr);
CARLA_ASSERT(numBytes > 0);
CARLA_ASSERT(numBytes != 0);

if (memory == nullptr || numBytes == 0)
return;


Loading…
Cancel
Save