mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
AudioProcessor: Allow querying of the host timestamp in processBlock
This commit is contained in:
parent
5d096b46d7
commit
cfa289d943
31 changed files with 496 additions and 185 deletions
|
|
@ -69,9 +69,14 @@ public:
|
|||
CallbackHandler (AudioDeviceManager& adm) noexcept : owner (adm) {}
|
||||
|
||||
private:
|
||||
void audioDeviceIOCallback (const float** ins, int numIns, float** outs, int numOuts, int numSamples) override
|
||||
void audioDeviceIOCallbackWithContext (const float** ins,
|
||||
int numIns,
|
||||
float** outs,
|
||||
int numOuts,
|
||||
int numSamples,
|
||||
const AudioIODeviceCallbackContext& context) override
|
||||
{
|
||||
owner.audioDeviceIOCallbackInt (ins, numIns, outs, numOuts, numSamples);
|
||||
owner.audioDeviceIOCallbackInt (ins, numIns, outs, numOuts, numSamples, context);
|
||||
}
|
||||
|
||||
void audioDeviceAboutToStart (AudioIODevice* device) override
|
||||
|
|
@ -900,7 +905,8 @@ void AudioDeviceManager::audioDeviceIOCallbackInt (const float** inputChannelDat
|
|||
int numInputChannels,
|
||||
float** outputChannelData,
|
||||
int numOutputChannels,
|
||||
int numSamples)
|
||||
int numSamples,
|
||||
const AudioIODeviceCallbackContext& context)
|
||||
{
|
||||
const ScopedLock sl (audioCallbackLock);
|
||||
|
||||
|
|
@ -912,15 +918,23 @@ void AudioDeviceManager::audioDeviceIOCallbackInt (const float** inputChannelDat
|
|||
|
||||
tempBuffer.setSize (jmax (1, numOutputChannels), jmax (1, numSamples), false, false, true);
|
||||
|
||||
callbacks.getUnchecked(0)->audioDeviceIOCallback (inputChannelData, numInputChannels,
|
||||
outputChannelData, numOutputChannels, numSamples);
|
||||
callbacks.getUnchecked(0)->audioDeviceIOCallbackWithContext (inputChannelData,
|
||||
numInputChannels,
|
||||
outputChannelData,
|
||||
numOutputChannels,
|
||||
numSamples,
|
||||
context);
|
||||
|
||||
auto** tempChans = tempBuffer.getArrayOfWritePointers();
|
||||
|
||||
for (int i = callbacks.size(); --i > 0;)
|
||||
{
|
||||
callbacks.getUnchecked(i)->audioDeviceIOCallback (inputChannelData, numInputChannels,
|
||||
tempChans, numOutputChannels, numSamples);
|
||||
callbacks.getUnchecked(i)->audioDeviceIOCallbackWithContext (inputChannelData,
|
||||
numInputChannels,
|
||||
tempChans,
|
||||
numOutputChannels,
|
||||
numSamples,
|
||||
context);
|
||||
|
||||
for (int chan = 0; chan < numOutputChannels; ++chan)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -526,8 +526,12 @@ private:
|
|||
class CallbackHandler;
|
||||
std::unique_ptr<CallbackHandler> callbackHandler;
|
||||
|
||||
void audioDeviceIOCallbackInt (const float** inputChannelData, int totalNumInputChannels,
|
||||
float** outputChannelData, int totalNumOutputChannels, int numSamples);
|
||||
void audioDeviceIOCallbackInt (const float** inputChannelData,
|
||||
int totalNumInputChannels,
|
||||
float** outputChannelData,
|
||||
int totalNumOutputChannels,
|
||||
int numSamples,
|
||||
const AudioIODeviceCallbackContext& context);
|
||||
void audioDeviceAboutToStartInt (AudioIODevice*);
|
||||
void audioDeviceStoppedInt();
|
||||
void audioDeviceErrorInt (const String&);
|
||||
|
|
|
|||
|
|
@ -25,6 +25,14 @@ namespace juce
|
|||
|
||||
class AudioIODevice;
|
||||
|
||||
/** Additional information that may be passed to the AudioIODeviceCallback. */
|
||||
struct AudioIODeviceCallbackContext
|
||||
{
|
||||
/** If the host provides this information, this field will be set to point to
|
||||
an integer holding the current value; otherwise, this will be nullptr.
|
||||
*/
|
||||
const uint64_t* hostTimeNs = nullptr;
|
||||
};
|
||||
|
||||
//==============================================================================
|
||||
/**
|
||||
|
|
@ -87,7 +95,26 @@ public:
|
|||
int numInputChannels,
|
||||
float** outputChannelData,
|
||||
int numOutputChannels,
|
||||
int numSamples) = 0;
|
||||
int numSamples)
|
||||
{
|
||||
ignoreUnused (inputChannelData, numInputChannels, outputChannelData, numOutputChannels, numSamples);
|
||||
}
|
||||
|
||||
/** The same as audioDeviceIOCallback(), but with an additional context argument.
|
||||
|
||||
The default implementation of this function will call audioDeviceIOCallback(),
|
||||
but you can override this function if you need to make use of the context information.
|
||||
*/
|
||||
virtual void audioDeviceIOCallbackWithContext (const float** inputChannelData,
|
||||
int numInputChannels,
|
||||
float** outputChannelData,
|
||||
int numOutputChannels,
|
||||
int numSamples,
|
||||
const AudioIODeviceCallbackContext& context)
|
||||
{
|
||||
audioDeviceIOCallback (inputChannelData, numInputChannels, outputChannelData, numOutputChannels, numSamples);
|
||||
ignoreUnused (context);
|
||||
}
|
||||
|
||||
/** Called to indicate that the device is about to start calling back.
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue