Is there a function that's called in PluginProcessor when the playHead is told to stop?

I know prepareToPlay() is called just as the playHead starts moving, and processBlock() is called while its moving continually.
But, is there a function called in the PluginProcessor when the playHead is told to stop?

I just want to have a look at some variables in terms of diagnostics and obviously wouldn’t like to do this as the plugin is running, but just after its stopped.

Don’t be to sure about prepareToPlay to happen directly before starting to process. The host can prepare the plugin but only start processing a few seconds or even minutes later.

Also the playhead stop does not mean the processing stops. First there is the tail of some plugins that will continue being processed, then there are tracks set to monitor, which also keep processing with stopped playhead.

And last but not least, the frequency the processBlock happens may also vary due to offline processing.

TL;DR: the host is not required to inform the plugin outside of the processBlock and most don’t do it in a predictable way.

1 Like

thanks, so there is no function that is predictably called after its “finished processing”. I just want to have a look at a list of variables (and a buffer) to check whats in them as a debug/diagnostic measure. My final plugin won’t have this debug stuff in.
How do you recommend I could do this debug? I thought I’d do it in the destructor but I’m pretty sure thats not a good idea because I imagine that its busy releasing those variables.

What I do is to check the playhead state every time processBlock() is called. You might debugLog your variables when switching from running to stopped. Here’s a snippet of my code ( from :

        AudioPlayHead::CurrentPositionInfo lastPosInfo;
	auto playHed = getPlayHead();
	if (playHed != nullptr)

		if (lastPosInfo.isPlaying && (runState != Topiary::Running)) // Armed as well to take into account??? Don't think so
			if (!override)
				// just arm it - if we get a note it will switch to playing if WFFN; else if will auto-switch before generating MIDI
				runState = model.getRunState();  // because the plugin may want to refuse to arm!!!
		} // detect we are playing depending on override
        else if (!override)
		{ // all other stuff we pick up from host transport
			if (!lastPosInfo.isPlaying && ((runState == Topiary::Running) || (runState == Topiary::Armed)))
				// we'll set model to Stopping; it will then decide to really stop when needed
					runState = Topiary::Ending;

thanks, I’ll have a look at that.

There’s the counterpart to prepareToPlay, the releaseResources method, but again there isn’t really any guarantees about when the host might be calling that.

I use something similar, but just discovered that if you are using Logic, and let the playhead run out past the audio on a track, and then stop the transport, our code is not able to detect the transport stopping. I’m still looking into why, but it’s as if once there is no more audio, Logic doesn’t call processBlock() with isPlaying set to false. It does if you stop it during the audio, but not after it passes the end of the audio. This is making it difficult to set our plugin state properly if the user lets it run past the audio before stopping.