13
0

allow to set custom thread-buffer size

This is needed for gain and pan automation buffers
as well as silent and scratch buffers when bouncing or
exporting with larger chunk size than the current engine
period.
This commit is contained in:
Robin Gareus 2014-05-26 06:21:05 +02:00
parent 491f3f6e44
commit bb727f4588
4 changed files with 14 additions and 9 deletions

View File

@ -40,7 +40,7 @@ public:
static ThreadBuffers* get_thread_buffers ();
static void put_thread_buffers (ThreadBuffers*);
static void ensure_buffers (ChanCount howmany = ChanCount::ZERO);
static void ensure_buffers (ChanCount howmany = ChanCount::ZERO, size_t custom = 0);
private:
static Glib::Threads::Mutex rb_mutex;

View File

@ -35,7 +35,7 @@ public:
ThreadBuffers ();
~ThreadBuffers ();
void ensure_buffers (ChanCount howmany = ChanCount::ZERO);
void ensure_buffers (ChanCount howmany = ChanCount::ZERO, size_t custom = 0);
BufferSet* silent_buffers;
BufferSet* scratch_buffers;

View File

@ -75,11 +75,11 @@ BufferManager::put_thread_buffers (ThreadBuffers* tbp)
}
void
BufferManager::ensure_buffers (ChanCount howmany)
BufferManager::ensure_buffers (ChanCount howmany, size_t custom)
{
/* this is protected by the audioengine's process lock: we do not */
for (ThreadBufferList::iterator i = thread_buffers_list->begin(); i != thread_buffers_list->end(); ++i) {
(*i)->ensure_buffers (howmany);
(*i)->ensure_buffers (howmany, custom);
}
}

View File

@ -40,7 +40,7 @@ ThreadBuffers::ThreadBuffers ()
}
void
ThreadBuffers::ensure_buffers (ChanCount howmany)
ThreadBuffers::ensure_buffers (ChanCount howmany, size_t custom)
{
// std::cerr << "ThreadBuffers " << this << " resize buffers with count = " << howmany << std::endl;
@ -60,9 +60,14 @@ ThreadBuffers::ensure_buffers (ChanCount howmany)
for (DataType::iterator t = DataType::begin(); t != DataType::end(); ++t) {
size_t count = std::max (scratch_buffers->available().get(*t), howmany.get(*t));
size_t size = (*t == DataType::MIDI)
? _engine->raw_buffer_size (*t)
: _engine->raw_buffer_size (*t) / sizeof (Sample);
size_t size;
if (custom > 0) {
size = custom;
} else {
size = (*t == DataType::MIDI)
? _engine->raw_buffer_size (*t)
: _engine->raw_buffer_size (*t) / sizeof (Sample);
}
scratch_buffers->ensure_buffers (*t, count, size);
mix_buffers->ensure_buffers (*t, count, size);
@ -70,7 +75,7 @@ ThreadBuffers::ensure_buffers (ChanCount howmany)
route_buffers->ensure_buffers (*t, count, size);
}
size_t audio_buffer_size = _engine->raw_buffer_size (DataType::AUDIO) / sizeof (Sample);
size_t audio_buffer_size = custom > 0 ? custom : _engine->raw_buffer_size (DataType::AUDIO) / sizeof (Sample);
delete [] gain_automation_buffer;
gain_automation_buffer = new gain_t[audio_buffer_size];