diff options
author | Carl Hetherington <carl@carlh.net> | 2012-05-24 00:54:51 +0000 |
---|---|---|
committer | Carl Hetherington <carl@carlh.net> | 2012-05-24 00:54:51 +0000 |
commit | 37bc04f2305d9f8cf812db8dedfc97815c1c6dca (patch) | |
tree | 9ffe55d29c0616676573f539933dc3b0fcc1cfc4 /libs/ardour/audioregion.cc | |
parent | ba56c4bd032483d20c4815528a7df1a7894bed9a (diff) |
Opaque region bodies should overwrite whatever is already in
the buffer; fix crash when the sum of the fade in and out
is longer than the region.
git-svn-id: svn://localhost/ardour2/branches/3.0@12410 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/ardour/audioregion.cc')
-rw-r--r-- | libs/ardour/audioregion.cc | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/libs/ardour/audioregion.cc b/libs/ardour/audioregion.cc index 7b9c9a75fe..9cbbdcfe4e 100644 --- a/libs/ardour/audioregion.cc +++ b/libs/ardour/audioregion.cc @@ -586,8 +586,8 @@ AudioRegion::read_at (Sample *buf, Sample *mixdown_buffer, float *gain_buffer, /* READ DATA FROM THE SOURCE INTO mixdown_buffer. We can never read directly into buf, since it may contain data - from a transparent region `below' this one in the stack; we - must always mix. + from a region `below' this one in the stack, and our fades (if they exist) + may need to mix with the existing data. */ if (read_from_sources (_sources, _length, mixdown_buffer, position, to_read, chan_n) != to_read) { @@ -706,7 +706,14 @@ AudioRegion::read_at (Sample *buf, Sample *mixdown_buffer, float *gain_buffer, /* MIX THE REGION BODY FROM mixdown_buffer INTO buf */ - mix_buffers_no_gain (buf + fade_in_limit, mixdown_buffer + fade_in_limit, to_read - fade_in_limit - fade_out_limit); + framecnt_t const N = to_read - fade_in_limit - fade_out_limit; + if (N > 0) { + if (opaque ()) { + memcpy (buf + fade_in_limit, mixdown_buffer + fade_in_limit, N * sizeof (Sample)); + } else { + mix_buffers_no_gain (buf + fade_in_limit, mixdown_buffer + fade_in_limit, N); + } + } return to_read; } |