{
int idx = editIndexOf( readSpan.start, true, ce );
if( idx < 0 ) idx = -(idx + 2);
final long startR = decimHelps[ sub ].roundAdd - readSpan.start;
final List coll = editGetCollByStart( ce );
final MutableInt readyLen = new MutableInt( 0 );
final MutableInt busyLen = new MutableInt( 0 );
// someReady is a transient trick to keep a newly opened documented
// responsive (since it's zoomed out completely and due to the missing
// decimation drawWaveform would take ages)
boolean someReady = false;
DecimatedStake stake;
int chunkLen, discrepancy;
Span subSpan;
int readOffset, nextOffset = dataOffset;
int len = (int) (readSpan.getLength() >> decimHelps[ sub ].shift );
while( (len > 0) && (idx < coll.size()) ) {
stake = (DecimatedStake) coll.get( idx );
subSpan = new Span( Math.max( stake.getSpan().start, readSpan.start ),
Math.min( stake.getSpan().stop, readSpan.stop ));
stake.readFrames( sub, data, nextOffset, subSpan, readyLen, busyLen );
chunkLen = readyLen.value() + busyLen.value();
readOffset = nextOffset + readyLen.value(); // chunkLen;
nextOffset = (int) ((subSpan.stop + startR) >> decimHelps[ sub ].shift) + dataOffset;
discrepancy = nextOffset - readOffset;
len -= readyLen.value() + discrepancy;
if( readyLen.value() > 0 ) someReady = true;
if( busyLen.value() == 0 ) {
if( discrepancy > 0 ) {
if( readOffset > 0 ) {
for( int i = readOffset, k = readOffset - 1; i < nextOffset; i++ ) {
for( int j = 0; j < data.length; j++ ) {
data[ j ][ i ] = data[ j ][ k ];
}
}
}
}
} else {
final Span busySpan = new Span( subSpan.stop - (subSpan.getLength() * busyLen.value() / chunkLen),
subSpan.stop );
final int busyLastIdx = busyList.size() - 1;
if( busyLastIdx >= 0 ) {
final Span busySpan2 = (Span) busyList.get( busyLastIdx );
if( busySpan.touches( busySpan2 )) {