2 Copyright (C) 2010 Paul Davis
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 #include "ardour/buffer.h"
23 #include "ardour/buffer_manager.h"
24 #include "ardour/buffer_set.h"
25 #include "ardour/process_thread.h"
26 #include "ardour/thread_buffers.h"
28 using namespace ARDOUR;
32 Private<ThreadBuffers>* ProcessThread::_private_thread_buffers = 0;
35 release_thread_buffer (void* arg)
37 BufferManager::put_thread_buffers ((ThreadBuffers*) arg);
41 ProcessThread::init ()
43 if (_private_thread_buffers == 0) {
44 _private_thread_buffers = new Private<ThreadBuffers> (release_thread_buffer);
48 ProcessThread::ProcessThread ()
52 ProcessThread::~ProcessThread ()
57 ProcessThread::get_buffers ()
59 ThreadBuffers* tb = BufferManager::get_thread_buffers ();
62 _private_thread_buffers->set (tb);
66 ProcessThread::drop_buffers ()
68 ThreadBuffers* tb = _private_thread_buffers->get();
70 BufferManager::put_thread_buffers (tb);
71 _private_thread_buffers->set (0);
75 ProcessThread::get_silent_buffers (ChanCount count)
77 ThreadBuffers* tb = _private_thread_buffers->get();
80 BufferSet* sb = tb->silent_buffers;
83 assert(sb->available() >= count);
86 for (DataType::iterator t = DataType::begin(); t != DataType::end(); ++t) {
87 for (size_t i= 0; i < count.get(*t); ++i) {
88 sb->get(*t, i).clear();
96 ProcessThread::get_scratch_buffers (ChanCount count)
98 ThreadBuffers* tb = _private_thread_buffers->get();
101 BufferSet* sb = tb->scratch_buffers;
104 if (count != ChanCount::ZERO) {
105 assert(sb->available() >= count);
106 sb->set_count (count);
108 sb->set_count (sb->available());
115 ProcessThread::get_mix_buffers (ChanCount count)
117 ThreadBuffers* tb = _private_thread_buffers->get();
120 BufferSet* mb = tb->mix_buffers;
123 assert (mb->available() >= count);
124 mb->set_count(count);
129 ProcessThread::gain_automation_buffer()
131 ThreadBuffers* tb = _private_thread_buffers->get();
134 gain_t *g = tb->gain_automation_buffer;
140 ProcessThread::send_gain_automation_buffer()
142 ThreadBuffers* tb = _private_thread_buffers->get();
145 gain_t* g = tb->send_gain_automation_buffer;
151 ProcessThread::pan_automation_buffer()
153 ThreadBuffers* tb = _private_thread_buffers->get();
156 pan_t** p = tb->pan_automation_buffer;