13
0
livetrax/libs/ardour/process_thread.cc
Paul Davis a83157de45 remove babbling torrent of debug output
git-svn-id: svn://localhost/ardour2/branches/3.0@6889 d708f5d6-7413-0410-9779-e7cbd77b26cf
2010-04-13 21:05:59 +00:00

148 lines
3.3 KiB
C++

/*
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);
}
void
ProcessThread::drop_buffers ()
{
ThreadBuffers* tb = _private_thread_buffers->get();
assert (tb);
BufferManager::put_thread_buffers (tb);
_private_thread_buffers->set (0);
}
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;
}