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.
21 #include "ardour/audioengine.h"
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 _private_thread_buffers
= new Private
<ThreadBuffers
> (release_thread_buffer
);
46 ProcessThread::ProcessThread ()
51 ProcessThread::~ProcessThread ()
56 ProcessThread::get_buffers ()
58 ThreadBuffers
* tb
= BufferManager::get_thread_buffers ();
61 _private_thread_buffers
->set (tb
);
65 ProcessThread::drop_buffers ()
67 ThreadBuffers
* tb
= _private_thread_buffers
->get();
69 BufferManager::put_thread_buffers (tb
);
70 _private_thread_buffers
->set (0);
74 ProcessThread::get_silent_buffers (ChanCount count
)
76 ThreadBuffers
* tb
= _private_thread_buffers
->get();
79 BufferSet
* sb
= tb
->silent_buffers
;
82 assert(sb
->available() >= count
);
85 for (DataType::iterator t
= DataType::begin(); t
!= DataType::end(); ++t
) {
86 for (size_t i
= 0; i
< count
.get(*t
); ++i
) {
87 sb
->get(*t
, i
).clear();
95 ProcessThread::get_scratch_buffers (ChanCount count
)
97 ThreadBuffers
* tb
= _private_thread_buffers
->get();
100 BufferSet
* sb
= tb
->scratch_buffers
;
103 if (count
!= ChanCount::ZERO
) {
104 assert(sb
->available() >= count
);
105 sb
->set_count (count
);
107 sb
->set_count (sb
->available());
114 ProcessThread::get_mix_buffers (ChanCount count
)
116 ThreadBuffers
* tb
= _private_thread_buffers
->get();
119 BufferSet
* mb
= tb
->mix_buffers
;
122 assert (mb
->available() >= count
);
123 mb
->set_count(count
);
128 ProcessThread::gain_automation_buffer()
130 ThreadBuffers
* tb
= _private_thread_buffers
->get();
133 gain_t
*g
= tb
->gain_automation_buffer
;
139 ProcessThread::pan_automation_buffer()
141 ThreadBuffers
* tb
= _private_thread_buffers
->get();
144 pan_t
** p
= tb
->pan_automation_buffer
;