summaryrefslogtreecommitdiff
path: root/libs/ardour
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2008-02-23 15:00:53 +0000
committerPaul Davis <paul@linuxaudiosystems.com>2008-02-23 15:00:53 +0000
commit80c6243429ea1996ec0d3be2f42d33d92e5f578f (patch)
tree0dcd1c9f220963100b28fe7810b00c6f7a8e246e /libs/ardour
parent770c39dce16598835ae4c9e970c11fb6edfde348 (diff)
fix stupid uses of Session::get_silent_buffers() from crashing ardour
git-svn-id: svn://localhost/ardour2/branches/2.0-ongoing@3116 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/ardour')
-rw-r--r--libs/ardour/session.cc28
1 files changed, 28 insertions, 0 deletions
diff --git a/libs/ardour/session.cc b/libs/ardour/session.cc
index a992e89458..c1afa92684 100644
--- a/libs/ardour/session.cc
+++ b/libs/ardour/session.cc
@@ -4088,9 +4088,37 @@ Session::write_one_audio_track (AudioTrack& track, nframes_t start, nframes_t le
vector<Sample*>&
Session::get_silent_buffers (uint32_t howmany)
{
+ if (howmany > _silent_buffers.size()) {
+
+ error << string_compose (_("Programming error: get_silent_buffers() called for %1 buffers but only %2 exist"),
+ howmany, _silent_buffers.size()) << endmsg;
+
+ if (howmany > 1000) {
+ cerr << "ABSURD: more than 1000 silent buffers requested!\n";
+ abort ();
+ }
+
+ while (howmany > _silent_buffers.size()) {
+ Sample *p = 0;
+
+#ifdef NO_POSIX_MEMALIGN
+ p = (Sample *) malloc(current_block_size * sizeof(Sample));
+#else
+ if (posix_memalign((void **)&p,CPU_CACHE_ALIGN,current_block_size * 4) != 0) {
+ fatal << string_compose (_("Memory allocation error: posix_memalign (%1 * %2) failed (%3)"),
+ current_block_size, sizeof (Sample), strerror (errno))
+ << endmsg;
+ /*NOTREACHED*/
+ }
+#endif
+ _silent_buffers.push_back (p);
+ }
+ }
+
for (uint32_t i = 0; i < howmany; ++i) {
memset (_silent_buffers[i], 0, sizeof (Sample) * current_block_size);
}
+
return _silent_buffers;
}