I am doign a VST so host always asks for more blocks, my code looks like that:
void SCFilePlayer::process (float **inputs, float **outputs, long sampleFrames)
{
// do nothing if not playing
if ( !transport.isPlaying() )
return;
// prepare buffer in JUCE format, assume stero output
AudioSampleBuffer output (outputs, 2, sampleFrames);
// get next block from transport
AudioSourceChannelInfo info;
info.buffer = &output;
info.startSample = 0;
info.numSamples = output.getNumSamples();
transport.getNextAudioBlock( info );
}
In another place I called transport.stop() and I got this 1 sec delay. I found that the transport needs to process blocks until it stops but the isPlaying() returns false before the transport internal ‘stopped’ flag is true…so in order to avoid the 1 sec delay I removed the isPlaying() call and just keep sending blocks to the transport even after it stopped and it just ignores them and the code works, although maybe not very efficient, i didn’t check…
this is the code from JUCE, you can see playing becomes false but stopped is still not true…
void AudioTransportSource::stop()
{
if (playing)
{
callbackLock.enter();
playing = false;
callbackLock.exit();
int n = 500;
while (--n >= 0 && ! stopped)
Thread::sleep (2);
sendChangeMessage (this);
}
}