final int inTrnsLen, outTrnsLen;
final int minBlockSize, maxBlockSize, prefBlockSize;
final Set newOptions;
final RandomAccessRequester rar;
final long pasteLength, preMaxLen, postMaxLen;
final Span span;
// final int numClipChannels = 0;
boolean hasSelectedMarkers = false;
Track.Info ti;
Object val;
consc = new ConsumerContext();
consc.plugIn = plugIn;
consc.doc = doc;
context.setOption( KEY_CONSC, consc );
source = new RenderSource( context );
if( !AudioTracks.checkSyncedAudio( tis, consc.plugIn.getLengthPolicy() == RenderPlugIn.POLICY_MODIFY, null, hasSelectedAudio )) {
return; // FAILED;
}
source.validAudio = (consc.plugIn.getAudioPolicy() == RenderPlugIn.POLICY_MODIFY) && hasSelectedAudio.isSet();
for( int i = 0; i < tis.size(); i++ ) {
ti = (Track.Info) tis.get( i );
if( (ti.trail instanceof MarkerTrail) && ti.selected ) {
hasSelectedMarkers = true;
break;
}
}
source.validMarkers = (consc.plugIn.getMarkerPolicy() == RenderPlugIn.POLICY_MODIFY) && hasSelectedMarkers;
if( source.validMarkers ) source.markers = doc.markers.getCuttedTrail( context.getTimeSpan(), doc.markers.getDefaultTouchMode(), 0 );
consc.restoreUnused = plugIn.getUnselectedAudioPolicy() == RenderPlugIn.POLICY_MODIFY;
try {
if( !invokeProducerBegin( source, plugIn )) {
BasicWindowHandler.showErrorDialog( getWindow(), new IOException( getResourceString( "errAudioWillLooseSync" )), plugIn.getName() );
return; // FAILED;
}
// consStarted = true;
// remainingRead = context.getTimeSpan().getLength();
newOptions = context.getModifiedOptions();
if( newOptions.contains( RenderContext.KEY_MINBLOCKSIZE )) {
val = context.getOption( RenderContext.KEY_MINBLOCKSIZE );
minBlockSize = ((Integer) val).intValue();
} else {
minBlockSize = 1;
}
if( newOptions.contains( RenderContext.KEY_MAXBLOCKSIZE )) {
val = context.getOption( RenderContext.KEY_MAXBLOCKSIZE );
maxBlockSize = ((Integer) val).intValue();
} else {
maxBlockSize = 0x7FFFFF;
}
if( newOptions.contains( RenderContext.KEY_PREFBLOCKSIZE )) {
val = context.getOption( RenderContext.KEY_PREFBLOCKSIZE );
prefBlockSize = ((Integer) val).intValue();
} else {
prefBlockSize = Math.max( minBlockSize, Math.min( maxBlockSize, 1024 ));
}
if( newOptions.contains( RenderContext.KEY_RANDOMACCESS )) {
rar = (RandomAccessRequester) context.getOption( RenderContext.KEY_RANDOMACCESS );
// randomAccess = true;
} else {
rar = null;
}
if( newOptions.contains( RenderContext.KEY_CLIPBOARD )) {
return; // FAILED;
}
assert minBlockSize <= maxBlockSize : "minmaxblocksize";
inTrnsLen = prefBlockSize;
outTrnsLen = inTrnsLen;
// --- ---
for( int ch = 0; ch < source.numAudioChannels; ch++ ) {
source.audioBlockBuf[ ch ] = new float[ outTrnsLen ];
}
}
catch( IOException e1 ) {
GUIUtil.displayError( getWindow(), e1, plugIn.getName() );
return;
}
consc.inBuf = new float[ source.numAudioChannels ][ inTrnsLen ];
consc.outBuf = new float[ source.numAudioChannels ][];
pasteLength = context.getTimeSpan().getLength();
preMaxLen = pasteLength >> 1;
postMaxLen = pasteLength - preMaxLen;
consc.bcPre = doc.createBlendContext( preMaxLen, 0, source.validAudio );
consc.bcPost = doc.createBlendContext( postMaxLen, 0, source.validAudio );
span = context.getTimeSpan();
consc.blendPreSpan = consc.bcPre == null ? new Span() :
span.replaceStop( span.start + consc.bcPre.getLen() );
consc.blendPostSpan = consc.bcPost == null ? new Span() :
span.replaceStart( span.stop - consc.bcPost.getLen() );
progress = 0.0f;
// pt = new ProcessingThread( this, doc.getFrame(), doc.bird, plugIn.getName(), new Object[] { context, null },
// Session.DOOR_ALL );
pt = new ProcessingThread( this, doc.getFrame(), plugIn.getName() );