summaryrefslogtreecommitdiff
path: root/libs/ardour/thread_buffers.cc
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2011-10-23 20:28:20 +0000
committerDavid Robillard <d@drobilla.net>2011-10-23 20:28:20 +0000
commit040aef6cc315e2fda6f7ad2988fff1442519b7ec (patch)
tree04659b37b4aaf498f0510b63bed47c28a4ec87c5 /libs/ardour/thread_buffers.cc
parentf44d19fc84aa2f4a0ec4b7dbf7dc7fddead1e123 (diff)
Ensure we always have at least 1 MIDI buffer
git-svn-id: svn://localhost/ardour2/branches/3.0@10293 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/ardour/thread_buffers.cc')
-rw-r--r--libs/ardour/thread_buffers.cc43
1 files changed, 24 insertions, 19 deletions
diff --git a/libs/ardour/thread_buffers.cc b/libs/ardour/thread_buffers.cc
index f30edee572..99dd931375 100644
--- a/libs/ardour/thread_buffers.cc
+++ b/libs/ardour/thread_buffers.cc
@@ -28,40 +28,45 @@ using namespace ARDOUR;
using namespace std;
ThreadBuffers::ThreadBuffers ()
- : silent_buffers (new BufferSet)
- , scratch_buffers (new BufferSet)
- , mix_buffers (new BufferSet)
- , gain_automation_buffer (0)
- , pan_automation_buffer (0)
- , npan_buffers (0)
+ : silent_buffers (new BufferSet)
+ , scratch_buffers (new BufferSet)
+ , mix_buffers (new BufferSet)
+ , gain_automation_buffer (0)
+ , pan_automation_buffer (0)
+ , npan_buffers (0)
{
}
void
ThreadBuffers::ensure_buffers (ChanCount howmany)
{
- // std::cerr << "ThreadBuffers " << this << " resize buffers with count = " << howmany << std::endl;
+ // std::cerr << "ThreadBuffers " << this << " resize buffers with count = " << howmany << std::endl;
- /* this is all protected by the process lock in the Session
- */
+ /* this is all protected by the process lock in the Session
+ */
- if (howmany.n_total() == 0) {
- return;
- }
+ /* we always need at least 1 midi buffer */
+ if (howmany.n_midi() < 1) {
+ howmany.set_midi(1);
+ }
+
+ if (howmany.n_audio() == 0 && howmany.n_midi() == 1) {
+ return;
+ }
- AudioEngine* _engine = AudioEngine::instance ();
+ AudioEngine* _engine = AudioEngine::instance ();
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 = _engine->raw_buffer_size (*t);
+ size_t size = _engine->raw_buffer_size (*t);
scratch_buffers->ensure_buffers (*t, count, size);
mix_buffers->ensure_buffers (*t, count, size);
- silent_buffers->ensure_buffers (*t, count, size);
+ silent_buffers->ensure_buffers (*t, count, size);
}
- delete [] gain_automation_buffer;
- gain_automation_buffer = new gain_t[_engine->raw_buffer_size (DataType::AUDIO)];
+ delete [] gain_automation_buffer;
+ gain_automation_buffer = new gain_t[_engine->raw_buffer_size (DataType::AUDIO)];
allocate_pan_automation_buffers (_engine->raw_buffer_size (DataType::AUDIO), howmany.n_audio(), false);
}
@@ -69,9 +74,9 @@ ThreadBuffers::ensure_buffers (ChanCount howmany)
void
ThreadBuffers::allocate_pan_automation_buffers (framecnt_t nframes, uint32_t howmany, bool force)
{
- /* we always need at least 2 pan buffers */
+ /* we always need at least 2 pan buffers */
- howmany = max (2U, howmany);
+ howmany = max (2U, howmany);
if (!force && howmany <= npan_buffers) {
return;