mirror of
https://github.com/Ardour/ardour.git
synced 2026-01-04 04:39:33 +01:00
fix reverse play buffer refilling; turn on Blink signal again
git-svn-id: svn://localhost/ardour2/trunk@1464 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
parent
b8a6f94325
commit
7e277f96d7
6 changed files with 64 additions and 57 deletions
|
|
@ -982,7 +982,10 @@ AudioDiskstream::read (Sample* buf, Sample* mixdown_buffer, float* gain_buffer,
|
|||
nframes_t offset = 0;
|
||||
Location *loc = 0;
|
||||
|
||||
/* XXX we don't currently play loops in reverse. not sure why */
|
||||
|
||||
if (!reversed) {
|
||||
|
||||
/* Make the use of a Location atomic for this read operation.
|
||||
|
||||
Note: Locations don't get deleted, so all we care about
|
||||
|
|
@ -1006,11 +1009,16 @@ AudioDiskstream::read (Sample* buf, Sample* mixdown_buffer, float* gain_buffer,
|
|||
start = loop_start + ((start - loop_start) % loop_length);
|
||||
//cerr << "to " << start << endl;
|
||||
}
|
||||
|
||||
//cerr << "start is " << start << " loopstart: " << loop_start << " loopend: " << loop_end << endl;
|
||||
}
|
||||
|
||||
while (cnt) {
|
||||
|
||||
if (reversed) {
|
||||
start -= cnt;
|
||||
}
|
||||
|
||||
/* take any loop into account. we can't read past the end of the loop. */
|
||||
|
||||
if (loc && (loop_end - start < cnt)) {
|
||||
|
|
@ -1038,9 +1046,6 @@ AudioDiskstream::read (Sample* buf, Sample* mixdown_buffer, float* gain_buffer,
|
|||
|
||||
if (reversed) {
|
||||
|
||||
/* don't adjust start, since caller has already done that
|
||||
*/
|
||||
|
||||
swap_by_ptr (buf, buf + this_read - 1);
|
||||
|
||||
} else {
|
||||
|
|
@ -1096,7 +1101,7 @@ AudioDiskstream::_do_refill (Sample* mixdown_buffer, float* gain_buffer)
|
|||
if ((total_space = vector.len[0] + vector.len[1]) == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* if there are 2+ chunks of disk i/o possible for
|
||||
this track, let the caller know so that it can arrange
|
||||
for us to be called again, ASAP.
|
||||
|
|
@ -1126,6 +1131,8 @@ AudioDiskstream::_do_refill (Sample* mixdown_buffer, float* gain_buffer)
|
|||
return 0;
|
||||
}
|
||||
|
||||
/* never do more than disk_io_chunk_frames worth of disk input per call (limit doesn't apply for memset) */
|
||||
|
||||
total_space = min (disk_io_chunk_frames, total_space);
|
||||
|
||||
if (reversed) {
|
||||
|
|
@ -1159,11 +1166,6 @@ AudioDiskstream::_do_refill (Sample* mixdown_buffer, float* gain_buffer)
|
|||
|
||||
} else {
|
||||
|
||||
/* move read position backwards because we are going
|
||||
to reverse the data.
|
||||
*/
|
||||
|
||||
file_frame -= total_space;
|
||||
zero_fill = 0;
|
||||
}
|
||||
|
||||
|
|
@ -1209,21 +1211,36 @@ AudioDiskstream::_do_refill (Sample* mixdown_buffer, float* gain_buffer)
|
|||
|
||||
chan.playback_buf->get_write_vector (&vector);
|
||||
|
||||
if (vector.len[0] > disk_io_chunk_frames) {
|
||||
|
||||
/* we're not going to fill the first chunk, so certainly do not bother with the
|
||||
other part. it won't be connected with the part we do fill, as in:
|
||||
|
||||
.... => writable space
|
||||
++++ => readable space
|
||||
^^^^ => 1 x disk_io_chunk_frames that would be filled
|
||||
|
||||
|......|+++++++++++++|...............................|
|
||||
buf1 buf0
|
||||
^^^^^^^^^^^^^^^
|
||||
|
||||
|
||||
So, just pretend that the buf1 part isn't there.
|
||||
|
||||
*/
|
||||
|
||||
vector.buf[1] = 0;
|
||||
vector.len[1] = 0;
|
||||
|
||||
}
|
||||
|
||||
ts = total_space;
|
||||
file_frame_tmp = file_frame;
|
||||
|
||||
if (reversed) {
|
||||
buf1 = vector.buf[1];
|
||||
len1 = vector.len[1];
|
||||
buf2 = vector.buf[0];
|
||||
len2 = vector.len[0];
|
||||
} else {
|
||||
buf1 = vector.buf[0];
|
||||
len1 = vector.len[0];
|
||||
buf2 = vector.buf[1];
|
||||
len2 = vector.len[1];
|
||||
}
|
||||
|
||||
buf1 = vector.buf[0];
|
||||
len1 = vector.len[0];
|
||||
buf2 = vector.buf[1];
|
||||
len2 = vector.len[1];
|
||||
|
||||
to_read = min (ts, len1);
|
||||
to_read = min (to_read, disk_io_chunk_frames);
|
||||
|
|
@ -1234,7 +1251,7 @@ AudioDiskstream::_do_refill (Sample* mixdown_buffer, float* gain_buffer)
|
|||
ret = -1;
|
||||
goto out;
|
||||
}
|
||||
|
||||
|
||||
chan.playback_buf->increment_write_ptr (to_read);
|
||||
ts -= to_read;
|
||||
}
|
||||
|
|
@ -1243,7 +1260,6 @@ AudioDiskstream::_do_refill (Sample* mixdown_buffer, float* gain_buffer)
|
|||
|
||||
if (to_read) {
|
||||
|
||||
|
||||
/* we read all of vector.len[0], but it wasn't an entire disk_io_chunk_frames of data,
|
||||
so read some or all of vector.len[1] as well.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -79,6 +79,7 @@ AudioFilter::finish (boost::shared_ptr<AudioRegion> region, SourceList& nsrcs)
|
|||
boost::shared_ptr<AudioFileSource> afs = boost::dynamic_pointer_cast<AudioFileSource>(*si);
|
||||
if (afs) {
|
||||
afs->update_header (region->position(), *now, xnow);
|
||||
afs->mark_immutable ();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -47,10 +47,9 @@ Reverse::run (boost::shared_ptr<AudioRegion> region)
|
|||
{
|
||||
SourceList nsrcs;
|
||||
SourceList::iterator si;
|
||||
const nframes_t blocksize = 256 * 1048;
|
||||
Sample buf[blocksize];
|
||||
nframes_t blocksize = 256 * 1024;
|
||||
Sample* buf;
|
||||
nframes_t fpos;
|
||||
nframes_t fend;
|
||||
nframes_t fstart;
|
||||
nframes_t to_read;
|
||||
int ret = -1;
|
||||
|
|
@ -61,31 +60,34 @@ Reverse::run (boost::shared_ptr<AudioRegion> region)
|
|||
goto out;
|
||||
}
|
||||
|
||||
fend = region->start() + region->length();
|
||||
fstart = region->start();
|
||||
|
||||
if (blocksize < fend) {
|
||||
fpos =max(fstart, fend - blocksize);
|
||||
} else {
|
||||
fpos = fstart;
|
||||
if (blocksize > region->length()) {
|
||||
blocksize = region->length();
|
||||
}
|
||||
|
||||
to_read = min (region->length(), blocksize);
|
||||
fpos = max (fstart, (fstart + region->length() - blocksize));
|
||||
buf = new Sample[blocksize];
|
||||
to_read = blocksize;
|
||||
|
||||
cerr << "Reverse " << region->name() << " len = " << region->length() << " blocksize = " << blocksize << " start at " << fstart << endl;
|
||||
|
||||
/* now read it backwards */
|
||||
|
||||
while (1) {
|
||||
while (to_read) {
|
||||
|
||||
uint32_t n;
|
||||
|
||||
for (n = 0, si = nsrcs.begin(); n < region->n_channels(); ++n, ++si) {
|
||||
|
||||
/* read it in */
|
||||
|
||||
cerr << "read at " << fpos << " for " << to_read << endl;
|
||||
|
||||
if (region->source (n)->read (buf, fpos, to_read) != to_read) {
|
||||
goto out;
|
||||
}
|
||||
|
||||
|
||||
/* swap memory order */
|
||||
|
||||
for (nframes_t i = 0; i < to_read/2; ++i) {
|
||||
|
|
@ -99,13 +101,12 @@ Reverse::run (boost::shared_ptr<AudioRegion> region)
|
|||
}
|
||||
}
|
||||
|
||||
if (fpos == fstart) {
|
||||
break;
|
||||
} else if (fpos > fstart + to_read) {
|
||||
if (fpos > fstart + blocksize) {
|
||||
fpos -= to_read;
|
||||
to_read = min (fstart - fpos, blocksize);
|
||||
to_read = blocksize;
|
||||
} else {
|
||||
to_read = fpos-fstart;
|
||||
to_read = fpos - fstart;
|
||||
cerr << "Last read detected, only " << fpos - fstart << " left; move to start and read " << to_read << endl;
|
||||
fpos = fstart;
|
||||
}
|
||||
};
|
||||
|
|
@ -114,6 +115,8 @@ Reverse::run (boost::shared_ptr<AudioRegion> region)
|
|||
|
||||
out:
|
||||
|
||||
delete [] buf;
|
||||
|
||||
if (ret) {
|
||||
for (si = nsrcs.begin(); si != nsrcs.end(); ++si) {
|
||||
(*si)->mark_for_remove ();
|
||||
|
|
|
|||
|
|
@ -388,6 +388,8 @@ SndFileSource::nondestructive_write_unlocked (Sample *data, nframes_t cnt)
|
|||
|
||||
nframes_t oldlen;
|
||||
int32_t frame_pos = _length;
|
||||
|
||||
cerr << _name << " write " << cnt << " floats to " << frame_pos << endl;
|
||||
|
||||
if (write_float (data, frame_pos, cnt) != cnt) {
|
||||
return 0;
|
||||
|
|
@ -396,6 +398,8 @@ SndFileSource::nondestructive_write_unlocked (Sample *data, nframes_t cnt)
|
|||
oldlen = _length;
|
||||
update_length (oldlen, cnt);
|
||||
|
||||
cerr << "\t length is now " << _length << endl;
|
||||
|
||||
if (_build_peakfiles) {
|
||||
PeakBuildRecord *pbr = 0;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue