summaryrefslogtreecommitdiff
path: root/libs/ardour/buffer_manager.cc
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2010-04-13 20:48:33 +0000
committerPaul Davis <paul@linuxaudiosystems.com>2010-04-13 20:48:33 +0000
commit3ea10b38bbb4b471178793f68fbd3a0ee74449f6 (patch)
tree347a964476f8383aefcdfa94ce548cdfdf15e1d8 /libs/ardour/buffer_manager.cc
parent46ea5f5f5885dda6b10b75c104f726f6638c431e (diff)
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
Diffstat (limited to 'libs/ardour/buffer_manager.cc')
-rw-r--r--libs/ardour/buffer_manager.cc82
1 files changed, 82 insertions, 0 deletions
diff --git a/libs/ardour/buffer_manager.cc b/libs/ardour/buffer_manager.cc
new file mode 100644
index 0000000000..3436dac72d
--- /dev/null
+++ b/libs/ardour/buffer_manager.cc
@@ -0,0 +1,82 @@
+/*
+ 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/buffer_manager.h"
+#include "ardour/thread_buffers.h"
+
+using namespace ARDOUR;
+using namespace PBD;
+
+RingBufferNPT<ThreadBuffers*>* BufferManager::thread_buffers = 0;
+
+void
+BufferManager::init (uint32_t size)
+{
+ thread_buffers = new ThreadBufferFIFO (size+1); // must be one larger than requested
+
+ /* and populate with actual ThreadBuffers
+ */
+
+ std::cerr << "BM: initial read space: " << thread_buffers->read_space() << std::endl;
+
+ for (uint32_t n = 0; n < size; ++n) {
+ ThreadBuffers* ts = new ThreadBuffers;
+ thread_buffers->write (&ts, 1);
+ std::cerr << "BM: added one, read = " << thread_buffers->read_space()
+ << " write = " << thread_buffers->write_space()
+ << std::endl;
+ }
+
+ std::cerr << "BM: final, read = " << thread_buffers->read_space()
+ << " write = " << thread_buffers->write_space()
+ << std::endl;
+
+ std::cerr << "BUFFER MANAGER INITIALIZED WITH " << size << " BUFFERs\n";
+}
+
+ThreadBuffers*
+BufferManager::get_thread_buffers ()
+{
+ ThreadBuffers* tbp;
+
+ if (thread_buffers->read (&tbp, 1) == 1) {
+ return tbp;
+ }
+
+ return 0;
+}
+
+void
+BufferManager::put_thread_buffers (ThreadBuffers* tbp)
+{
+ thread_buffers->write (&tbp, 1);
+}
+
+void
+BufferManager::ensure_buffers (ChanCount howmany)
+{
+ /* this is protected by the audioengine's process lock: we do not */
+
+ std::cerr << "BufMgr: ensure " << thread_buffers->bufsize() - 1 << " buffers match " << howmany << std::endl;
+
+ for (uint32_t n = 0; n < thread_buffers->bufsize() - 1; ++n) {
+ thread_buffers->buffer()[n]->ensure_buffers (howmany);
+ }
+}