2010-04-13 16:48:33 -04:00
|
|
|
/*
|
|
|
|
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>
|
2012-05-24 02:09:29 -04:00
|
|
|
|
2010-04-13 16:48:33 -04:00
|
|
|
#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;
|
|
|
|
|
2011-06-01 12:50:12 -04:00
|
|
|
static void
|
2010-04-13 16:48:33 -04:00
|
|
|
release_thread_buffer (void* arg)
|
|
|
|
{
|
|
|
|
BufferManager::put_thread_buffers ((ThreadBuffers*) arg);
|
|
|
|
}
|
|
|
|
|
2012-07-25 13:48:55 -04:00
|
|
|
Glib::Threads::Private<ThreadBuffers> ProcessThread::_private_thread_buffers (release_thread_buffer);
|
|
|
|
|
2010-04-13 16:48:33 -04:00
|
|
|
void
|
|
|
|
ProcessThread::init ()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
ProcessThread::ProcessThread ()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
ProcessThread::~ProcessThread ()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ProcessThread::get_buffers ()
|
|
|
|
{
|
|
|
|
ThreadBuffers* tb = BufferManager::get_thread_buffers ();
|
|
|
|
|
|
|
|
assert (tb);
|
2012-07-25 13:48:55 -04:00
|
|
|
_private_thread_buffers.set (tb);
|
2010-04-13 16:48:33 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ProcessThread::drop_buffers ()
|
|
|
|
{
|
2012-07-25 13:48:55 -04:00
|
|
|
ThreadBuffers* tb = _private_thread_buffers.get();
|
2010-04-13 16:48:33 -04:00
|
|
|
assert (tb);
|
|
|
|
BufferManager::put_thread_buffers (tb);
|
2012-07-25 13:48:55 -04:00
|
|
|
_private_thread_buffers.set (0);
|
2010-04-13 16:48:33 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
BufferSet&
|
|
|
|
ProcessThread::get_silent_buffers (ChanCount count)
|
|
|
|
{
|
2012-07-25 13:48:55 -04:00
|
|
|
ThreadBuffers* tb = _private_thread_buffers.get();
|
2010-04-13 16:48:33 -04:00
|
|
|
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&
|
2013-07-31 18:35:24 -04:00
|
|
|
ProcessThread::get_scratch_buffers (ChanCount count, bool silence)
|
2010-04-13 16:48:33 -04:00
|
|
|
{
|
2012-07-25 13:48:55 -04:00
|
|
|
ThreadBuffers* tb = _private_thread_buffers.get();
|
2010-04-13 16:48:33 -04:00
|
|
|
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());
|
|
|
|
}
|
|
|
|
|
2013-07-31 18:35:24 -04:00
|
|
|
if (silence) {
|
|
|
|
for (DataType::iterator t = DataType::begin(); t != DataType::end(); ++t) {
|
|
|
|
for (uint32_t i = 0; i < sb->count().get(*t); ++i) {
|
|
|
|
sb->get(*t, i).clear();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-04-13 16:48:33 -04:00
|
|
|
return *sb;
|
|
|
|
}
|
|
|
|
|
2016-03-25 19:40:51 -04:00
|
|
|
BufferSet&
|
|
|
|
ProcessThread::get_noinplace_buffers (ChanCount count)
|
|
|
|
{
|
|
|
|
ThreadBuffers* tb = _private_thread_buffers.get();
|
|
|
|
assert (tb);
|
|
|
|
|
|
|
|
BufferSet* sb = tb->noinplace_buffers;
|
|
|
|
assert (sb);
|
|
|
|
|
|
|
|
if (count != ChanCount::ZERO) {
|
|
|
|
assert(sb->available() >= count);
|
|
|
|
sb->set_count (count);
|
|
|
|
} else {
|
|
|
|
sb->set_count (sb->available());
|
|
|
|
}
|
|
|
|
|
|
|
|
return *sb;
|
|
|
|
}
|
|
|
|
|
2013-07-30 10:55:33 -04:00
|
|
|
BufferSet&
|
|
|
|
ProcessThread::get_route_buffers (ChanCount count, bool silence)
|
|
|
|
{
|
|
|
|
ThreadBuffers* tb = _private_thread_buffers.get();
|
|
|
|
assert (tb);
|
|
|
|
|
2013-07-30 20:00:31 -04:00
|
|
|
BufferSet* sb = tb->route_buffers;
|
2013-07-30 10:55:33 -04:00
|
|
|
assert (sb);
|
|
|
|
|
|
|
|
if (count != ChanCount::ZERO) {
|
|
|
|
assert(sb->available() >= count);
|
|
|
|
sb->set_count (count);
|
|
|
|
} else {
|
|
|
|
sb->set_count (sb->available());
|
|
|
|
}
|
|
|
|
|
|
|
|
if (silence) {
|
|
|
|
for (DataType::iterator t = DataType::begin(); t != DataType::end(); ++t) {
|
2013-07-31 08:21:40 -04:00
|
|
|
for (uint32_t i = 0; i < sb->count().get(*t); ++i) {
|
2013-07-30 10:55:33 -04:00
|
|
|
sb->get(*t, i).clear();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return *sb;
|
|
|
|
}
|
|
|
|
|
2010-04-13 16:48:33 -04:00
|
|
|
BufferSet&
|
|
|
|
ProcessThread::get_mix_buffers (ChanCount count)
|
|
|
|
{
|
2012-07-25 13:48:55 -04:00
|
|
|
ThreadBuffers* tb = _private_thread_buffers.get();
|
2010-04-13 16:48:33 -04:00
|
|
|
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()
|
|
|
|
{
|
2012-07-25 13:48:55 -04:00
|
|
|
ThreadBuffers* tb = _private_thread_buffers.get();
|
2010-04-13 16:48:33 -04:00
|
|
|
assert (tb);
|
|
|
|
|
|
|
|
gain_t *g = tb->gain_automation_buffer;
|
|
|
|
assert (g);
|
|
|
|
return g;
|
|
|
|
}
|
|
|
|
|
2015-04-25 15:24:58 -04:00
|
|
|
gain_t*
|
|
|
|
ProcessThread::trim_automation_buffer()
|
|
|
|
{
|
|
|
|
ThreadBuffers* tb = _private_thread_buffers.get();
|
|
|
|
assert (tb);
|
|
|
|
|
|
|
|
gain_t *g = tb->trim_automation_buffer;
|
|
|
|
assert (g);
|
|
|
|
return g;
|
|
|
|
}
|
|
|
|
|
2012-06-11 06:42:30 -04:00
|
|
|
gain_t*
|
|
|
|
ProcessThread::send_gain_automation_buffer()
|
|
|
|
{
|
2012-07-25 13:48:55 -04:00
|
|
|
ThreadBuffers* tb = _private_thread_buffers.get();
|
2012-06-11 06:42:30 -04:00
|
|
|
assert (tb);
|
|
|
|
|
|
|
|
gain_t* g = tb->send_gain_automation_buffer;
|
|
|
|
assert (g);
|
|
|
|
return g;
|
|
|
|
}
|
|
|
|
|
2010-04-13 16:48:33 -04:00
|
|
|
pan_t**
|
|
|
|
ProcessThread::pan_automation_buffer()
|
|
|
|
{
|
2012-07-25 13:48:55 -04:00
|
|
|
ThreadBuffers* tb = _private_thread_buffers.get();
|
2010-04-13 16:48:33 -04:00
|
|
|
assert (tb);
|
|
|
|
|
|
|
|
pan_t** p = tb->pan_automation_buffer;
|
|
|
|
assert (p);
|
|
|
|
return p;
|
|
|
|
}
|