From 2bccce2f6fdfacf069755fc65b4fb62286d1ded5 Mon Sep 17 00:00:00 2001 From: jules Date: Tue, 3 Feb 2015 09:54:14 +0000 Subject: [PATCH] Improved a couple of comments. --- .../processors/juce_AudioPlayHead.h | 6 ++++-- .../processors/juce_AudioProcessor.h | 14 ++++++++++---- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/modules/juce_audio_processors/processors/juce_AudioPlayHead.h b/modules/juce_audio_processors/processors/juce_AudioPlayHead.h index b92b802f92..e3247b52b7 100644 --- a/modules/juce_audio_processors/processors/juce_AudioPlayHead.h +++ b/modules/juce_audio_processors/processors/juce_AudioPlayHead.h @@ -130,8 +130,10 @@ public: /** Fills-in the given structure with details about the transport's position at the start of the current processing block. - This method must ONLY be called from within your AudioProcessor::processBlock() - method. Calling it at any other time will probably cause a nasty crash. + You can ONLY call this from your processBlock() method! Calling it at other + times will produce undefined behaviour, as the host may not have any context + in which a time would make sense, and some hosts will almost certainly have + multithreading issues if it's not called on the audio thread. */ virtual bool getCurrentPosition (CurrentPositionInfo& result) = 0; }; diff --git a/modules/juce_audio_processors/processors/juce_AudioProcessor.h b/modules/juce_audio_processors/processors/juce_AudioProcessor.h index aaae9ef172..ea81339765 100644 --- a/modules/juce_audio_processors/processors/juce_AudioProcessor.h +++ b/modules/juce_audio_processors/processors/juce_AudioProcessor.h @@ -140,11 +140,17 @@ public: /** Returns the current AudioPlayHead object that should be used to find out the state and position of the playhead. - You can call this from your processBlock() method, and use the AudioPlayHead - object to get the details about the time of the start of the block currently - being processed. + You can ONLY call this from your processBlock() method! Calling it at other + times will produce undefined behaviour, as the host may not have any context + in which a time would make sense, and some hosts will almost certainly have + multithreading issues if it's not called on the audio thread. - If the host hasn't supplied a playhead object, this will return nullptr. + The AudioPlayHead object that is returned can be used to get the details about + the time of the start of the block currently being processed. But do not + store this pointer or use it outside of the current audio callback, because + the host may delete or re-use it. + + If the host can't or won't provide any time info, this will return nullptr. */ AudioPlayHead* getPlayHead() const noexcept { return playHead; }