summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2011-06-01 01:09:34 +0000
committerPaul Davis <paul@linuxaudiosystems.com>2011-06-01 01:09:34 +0000
commit9a091eb3049266ed9e08906826f5ff635be455f8 (patch)
treeee2db66b71dde598a695cab1b34aebe0f5aab15a
parent71a32f5a000f852dc849e6e677e3a45b95bb0e7f (diff)
fix reallocation of silent, passthru and send buffers, specifically after a reconnect to JACK, so that we retain AT LEAST as many of each kind of buffer as we had before
git-svn-id: svn://localhost/ardour2/branches/2.0-ongoing@9650 d708f5d6-7413-0410-9779-e7cbd77b26cf
-rw-r--r--libs/ardour/session.cc107
1 files changed, 56 insertions, 51 deletions
diff --git a/libs/ardour/session.cc b/libs/ardour/session.cc
index 49d3858704..12220e8189 100644
--- a/libs/ardour/session.cc
+++ b/libs/ardour/session.cc
@@ -1519,41 +1519,15 @@ Session::set_block_size (nframes_t nframes)
{
vector<Sample*>::iterator i;
- uint32_t np;
current_block_size = nframes;
- for (np = 0, i = _passthru_buffers.begin(); i != _passthru_buffers.end(); ++i, ++np) {
- free (*i);
- }
-
- for (vector<Sample*>::iterator i = _silent_buffers.begin(); i != _silent_buffers.end(); ++i) {
- free (*i);
- }
-
- _passthru_buffers.clear ();
- _silent_buffers.clear ();
-
- ensure_passthru_buffers (np);
-
- for (vector<Sample*>::iterator i = _send_buffers.begin(); i != _send_buffers.end(); ++i) {
- free(*i);
-
- Sample *buf;
-#ifdef NO_POSIX_MEMALIGN
- buf = (Sample *) malloc(current_block_size * sizeof(Sample));
-#else
- posix_memalign((void **)&buf,CPU_CACHE_ALIGN,current_block_size * sizeof(Sample));
-#endif
- *i = buf;
+ ensure_passthru_buffers (_passthru_buffers.size());
- memset (*i, 0, sizeof (Sample) * current_block_size);
- }
-
-
if (_gain_automation_buffer) {
delete [] _gain_automation_buffer;
}
+
_gain_automation_buffer = new gain_t[nframes];
allocate_pan_automation_buffers (nframes, _npan_buffers, true);
@@ -3906,50 +3880,81 @@ Session::tempo_map_changed (Change ignored)
void
Session::ensure_passthru_buffers (uint32_t howmany)
{
+ vector<Sample*>::iterator i;
+ Sample *buf;
+
if (current_block_size == 0) {
return;
}
- while (howmany > _passthru_buffers.size()) {
- Sample *p;
+ while (_passthru_buffers.size() < howmany) {
+ _passthru_buffers.push_back (0);
+ }
+
+ for (i = _passthru_buffers.begin(); i != _passthru_buffers.end(); ++i) {
+
+ if (*i) {
+ free (*i);
+ }
+
#ifdef NO_POSIX_MEMALIGN
- p = (Sample *) malloc(current_block_size * sizeof(Sample));
+ buf = (Sample *) malloc(current_block_size * sizeof(Sample));
#else
- if (posix_memalign((void **)&p,CPU_CACHE_ALIGN,current_block_size * sizeof(Sample)) != 0) {
+ if (posix_memalign((void **)&buf,CPU_CACHE_ALIGN,current_block_size * sizeof(Sample)) != 0) {
fatal << string_compose (_("Memory allocation error: posix_memalign (%1 * %2) failed (%3)"),
current_block_size, sizeof (Sample), strerror (errno))
<< endmsg;
/*NOTREACHED*/
}
#endif
- _passthru_buffers.push_back (p);
+ (*i) = buf;
+ }
+
+ while (_passthru_buffers.size() < howmany) {
+ _passthru_buffers.push_back (0);
+ }
- *p = 0;
+ for (i = _send_buffers.begin(); i != _send_buffers.end(); ++i) {
+
+ if (*i) {
+ free (*i);
+ }
#ifdef NO_POSIX_MEMALIGN
- p = (Sample *) malloc(current_block_size * sizeof(Sample));
+ buf = (Sample *) malloc(current_block_size * sizeof(Sample));
#else
- if (posix_memalign((void **)&p,CPU_CACHE_ALIGN,current_block_size * sizeof(Sample)) != 0) {
- fatal << string_compose (_("Memory allocation error: posix_memalign (%1 * %2) failed (%3)"),
- current_block_size, sizeof (Sample), strerror (errno))
- << endmsg;
- /*NOTREACHED*/
- }
+ posix_memalign((void **)&buf,CPU_CACHE_ALIGN,current_block_size * sizeof(Sample));
#endif
- memset (p, 0, sizeof (Sample) * current_block_size);
- _silent_buffers.push_back (p);
+ memset (buf, 0, sizeof (Sample) * current_block_size);
+
+ (*i) = buf;
+ }
+
+ while (_silent_buffers.size() < howmany) {
+ _silent_buffers.push_back (0);
+ }
+
+ for (i = _silent_buffers.begin(); i != _silent_buffers.end(); ++i) {
+
+ if (*i) {
+ free (*i);
+ }
- *p = 0;
-
#ifdef NO_POSIX_MEMALIGN
- p = (Sample *) malloc(current_block_size * sizeof(Sample));
+ buf = (Sample *) malloc(current_block_size * sizeof(Sample));
#else
- posix_memalign((void **)&p,CPU_CACHE_ALIGN,current_block_size * sizeof(Sample));
+ if (posix_memalign((void **)&buf,CPU_CACHE_ALIGN,current_block_size * sizeof(Sample)) != 0) {
+ fatal << string_compose (_("Memory allocation error: posix_memalign (%1 * %2) failed (%3)"),
+ current_block_size, sizeof (Sample), strerror (errno))
+ << endmsg;
+ /*NOTREACHED*/
+ }
#endif
- memset (p, 0, sizeof (Sample) * current_block_size);
- _send_buffers.push_back (p);
-
- }
+
+ memset (buf, 0, sizeof (Sample) * current_block_size);
+ (*i) = buf;
+ }
+
allocate_pan_automation_buffers (current_block_size, howmany, false);
}