summaryrefslogtreecommitdiff
path: root/libs/ardour/process_thread.cc
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2010-04-13 20:48:33 +0000
committerPaul Davis <paul@linuxaudiosystems.com>2010-04-13 20:48:33 +0000
commit3ea10b38bbb4b471178793f68fbd3a0ee74449f6 (patch)
tree347a964476f8383aefcdfa94ce548cdfdf15e1d8 /libs/ardour/process_thread.cc
parent46ea5f5f5885dda6b10b75c104f726f6638c431e (diff)
substantive change: use the JACK wait API and provide "thread buffers" separately from session in preparation for parallelization. lots of debug output at present. If using JACK1, requires a very current version of JACK1 SVN (0.119.0)
git-svn-id: svn://localhost/ardour2/branches/3.0@6888 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/ardour/process_thread.cc')
-rw-r--r--libs/ardour/process_thread.cc149
1 files changed, 149 insertions, 0 deletions
diff --git a/libs/ardour/process_thread.cc b/libs/ardour/process_thread.cc
new file mode 100644
index 0000000000..e36639aaf5
--- /dev/null
+++ b/libs/ardour/process_thread.cc
@@ -0,0 +1,149 @@
+/*
+ Copyright (C) 2010 Paul Davis
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+*/
+
+#include <iostream>
+#include "ardour/audioengine.h"
+#include "ardour/buffer.h"
+#include "ardour/buffer_manager.h"
+#include "ardour/buffer_set.h"
+#include "ardour/process_thread.h"
+#include "ardour/thread_buffers.h"
+
+using namespace ARDOUR;
+using namespace Glib;
+using namespace std;
+
+Private<ThreadBuffers>* ProcessThread::_private_thread_buffers = 0;
+
+static void
+release_thread_buffer (void* arg)
+{
+ BufferManager::put_thread_buffers ((ThreadBuffers*) arg);
+}
+
+void
+ProcessThread::init ()
+{
+ _private_thread_buffers = new Private<ThreadBuffers> (release_thread_buffer);
+}
+
+ProcessThread::ProcessThread ()
+ : _thread (0)
+{
+}
+
+ProcessThread::~ProcessThread ()
+{
+}
+
+void
+ProcessThread::get_buffers ()
+{
+ ThreadBuffers* tb = BufferManager::get_thread_buffers ();
+
+ assert (tb);
+ _private_thread_buffers->set (tb);
+ cerr << "ProcThread " << this << " using TBs at " << tb << " (aka. " << _private_thread_buffers->get() << endl;
+}
+
+void
+ProcessThread::drop_buffers ()
+{
+ ThreadBuffers* tb = _private_thread_buffers->get();
+ assert (tb);
+ BufferManager::put_thread_buffers (tb);
+ _private_thread_buffers->set (0);
+ cerr << "ProcThread " << this << " dropped TBs\n";
+}
+
+BufferSet&
+ProcessThread::get_silent_buffers (ChanCount count)
+{
+ ThreadBuffers* tb = _private_thread_buffers->get();
+ assert (tb);
+
+ BufferSet* sb = tb->silent_buffers;
+ assert (sb);
+
+ assert(sb->available() >= count);
+ sb->set_count(count);
+
+ for (DataType::iterator t = DataType::begin(); t != DataType::end(); ++t) {
+ for (size_t i= 0; i < count.get(*t); ++i) {
+ sb->get(*t, i).clear();
+ }
+ }
+
+ return *sb;
+}
+
+BufferSet&
+ProcessThread::get_scratch_buffers (ChanCount count)
+{
+ ThreadBuffers* tb = _private_thread_buffers->get();
+ assert (tb);
+
+ BufferSet* sb = tb->scratch_buffers;
+ assert (sb);
+
+ if (count != ChanCount::ZERO) {
+ assert(sb->available() >= count);
+ sb->set_count (count);
+ } else {
+ sb->set_count (sb->available());
+ }
+
+ return *sb;
+}
+
+BufferSet&
+ProcessThread::get_mix_buffers (ChanCount count)
+{
+ ThreadBuffers* tb = _private_thread_buffers->get();
+ assert (tb);
+
+ BufferSet* mb = tb->mix_buffers;
+
+ assert (mb);
+ assert (mb->available() >= count);
+ mb->set_count(count);
+ return *mb;
+}
+
+gain_t*
+ProcessThread::gain_automation_buffer()
+{
+ ThreadBuffers* tb = _private_thread_buffers->get();
+ assert (tb);
+
+ gain_t *g = tb->gain_automation_buffer;
+ assert (g);
+ return g;
+}
+
+pan_t**
+ProcessThread::pan_automation_buffer()
+{
+ ThreadBuffers* tb = _private_thread_buffers->get();
+ assert (tb);
+
+ pan_t** p = tb->pan_automation_buffer;
+ assert (p);
+ return p;
+}