mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-20 21:56:30 +01:00
DiskReader::overwrite_existing_audio() now only overwrites data that would be read
There's no need to fill the whole buffer, because we do not consider the whole buffer readable. This uses the recently-added PlaybackBuffer::overwritable_at() API to compute the correct amount of data to overwrite
This commit is contained in:
parent
af46adc110
commit
5b7c20453f
1 changed files with 14 additions and 10 deletions
|
|
@ -687,38 +687,42 @@ DiskReader::overwrite_existing_audio ()
|
|||
samplecnt_t chunk1_cnt;
|
||||
samplecnt_t chunk2_cnt;
|
||||
|
||||
const samplecnt_t bufsize = c->front ()->rbuf->bufsize ();
|
||||
const samplecnt_t to_overwrite = c->front()->rbuf->overwritable_at (overwrite_offset);
|
||||
|
||||
chunk1_offset = overwrite_offset;
|
||||
chunk1_cnt = bufsize - overwrite_offset;
|
||||
chunk1_cnt = min (c->front()->rbuf->bufsize() - overwrite_offset, to_overwrite);
|
||||
|
||||
if (chunk1_cnt == bufsize) {
|
||||
if (chunk1_cnt == to_overwrite) {
|
||||
chunk1_cnt--;
|
||||
chunk2_cnt = 0;
|
||||
} else {
|
||||
chunk2_cnt = bufsize - 1 - chunk1_cnt;
|
||||
chunk2_cnt = to_overwrite - chunk1_cnt;
|
||||
}
|
||||
|
||||
/* this is a complete buffer fill */
|
||||
assert (chunk1_cnt + chunk2_cnt == bufsize - 1);
|
||||
|
||||
boost::scoped_array<Sample> mixdown_buffer (new Sample[bufsize]);
|
||||
boost::scoped_array<float> gain_buffer (new float[bufsize]);
|
||||
boost::scoped_array<Sample> mixdown_buffer (new Sample[to_overwrite]);
|
||||
boost::scoped_array<float> gain_buffer (new float[to_overwrite]);
|
||||
uint32_t n = 0;
|
||||
bool ret = true;
|
||||
samplepos_t start;
|
||||
|
||||
for (ChannelList::iterator chan = c->begin (); chan != c->end (); ++chan, ++n) {
|
||||
samplepos_t start = overwrite_sample;
|
||||
|
||||
Sample* buf = (*chan)->rbuf->buffer ();
|
||||
ReaderChannelInfo* rci = dynamic_cast<ReaderChannelInfo*> (*chan);
|
||||
|
||||
/* Note that @param start is passed by reference and will be
|
||||
* updated by the ::audio_read() call
|
||||
*/
|
||||
|
||||
start = overwrite_sample;
|
||||
|
||||
if (chunk1_cnt) {
|
||||
if (audio_read (buf + chunk1_offset, mixdown_buffer.get (), gain_buffer.get (), start, chunk1_cnt, rci, n, reversed) != chunk1_cnt) {
|
||||
error << string_compose (_("DiskReader %1: when overwriting(1), cannot read %2 from playlist at sample %3"), id (), chunk1_cnt, overwrite_sample) << endmsg;
|
||||
ret = false;
|
||||
continue;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (chunk2_cnt) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue