From 3ea10b38bbb4b471178793f68fbd3a0ee74449f6 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Tue, 13 Apr 2010 20:48:33 +0000 Subject: 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 --- libs/ardour/process_thread.cc | 149 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 149 insertions(+) create mode 100644 libs/ardour/process_thread.cc (limited to 'libs/ardour/process_thread.cc') 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 +#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* 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 (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; +} -- cgit v1.2.3