mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-09 23:34:20 +00:00
Remove AudioIODeviceCallback::audioDeviceIOCallback
This commit is contained in:
parent
f075de78fa
commit
c97864d7f3
12 changed files with 83 additions and 53 deletions
|
|
@ -4,6 +4,26 @@ JUCE breaking changes
|
|||
develop
|
||||
=======
|
||||
|
||||
Change
|
||||
------
|
||||
The function AudioIODeviceCallback::audioDeviceIOCallback() was removed.
|
||||
|
||||
Possible Issues
|
||||
---------------
|
||||
Code overriding audioDeviceIOCallback() will fail to compile.
|
||||
|
||||
Workaround
|
||||
----------
|
||||
Affected classes should override the audioDeviceIOCallbackWithContext() function
|
||||
instead.
|
||||
|
||||
Rationale
|
||||
---------
|
||||
The audioDeviceIOCallbackWithContext() function fulfills the same role as
|
||||
audioDeviceIOCallback(), it just has an extra parameter. Hence the
|
||||
audioDeviceIOCallback() function was superfluous.
|
||||
|
||||
|
||||
Change
|
||||
------
|
||||
The type representing multi-channel audio data has been changed from T** to
|
||||
|
|
|
|||
|
|
@ -45,10 +45,12 @@ public:
|
|||
clear();
|
||||
}
|
||||
|
||||
void audioDeviceIOCallback (const float* const* inputChannelData, int numInputChannels,
|
||||
float* const* outputChannelData, int numOutputChannels,
|
||||
int numberOfSamples) override
|
||||
void audioDeviceIOCallbackWithContext (const float* const* inputChannelData, int numInputChannels,
|
||||
float* const* outputChannelData, int numOutputChannels,
|
||||
int numberOfSamples, const AudioIODeviceCallbackContext& context) override
|
||||
{
|
||||
ignoreUnused (context);
|
||||
|
||||
for (int i = 0; i < numberOfSamples; ++i)
|
||||
{
|
||||
float inputSample = 0;
|
||||
|
|
|
|||
|
|
@ -136,9 +136,12 @@ public:
|
|||
|
||||
void audioDeviceStopped() override {}
|
||||
|
||||
void audioDeviceIOCallback (const float* const* inputChannelData, int numInputChannels,
|
||||
float* const* outputChannelData, int numOutputChannels, int numSamples) override
|
||||
void audioDeviceIOCallbackWithContext (const float* const* inputChannelData, int numInputChannels,
|
||||
float* const* outputChannelData, int numOutputChannels,
|
||||
int numSamples, const AudioIODeviceCallbackContext& context) override
|
||||
{
|
||||
ignoreUnused (context);
|
||||
|
||||
const ScopedLock sl (lock);
|
||||
|
||||
if (testIsRunning)
|
||||
|
|
|
|||
|
|
@ -134,10 +134,12 @@ public:
|
|||
sampleRate = 0;
|
||||
}
|
||||
|
||||
void audioDeviceIOCallback (const float* const* inputChannelData, int numInputChannels,
|
||||
float* const* outputChannelData, int numOutputChannels,
|
||||
int numSamples) override
|
||||
void audioDeviceIOCallbackWithContext (const float* const* inputChannelData, int numInputChannels,
|
||||
float* const* outputChannelData, int numOutputChannels,
|
||||
int numSamples, const AudioIODeviceCallbackContext& context) override
|
||||
{
|
||||
ignoreUnused (context);
|
||||
|
||||
const ScopedLock sl (writerLock);
|
||||
|
||||
if (activeWriter.load() != nullptr && numInputChannels >= thumbnail.getNumChannels())
|
||||
|
|
|
|||
|
|
@ -689,10 +689,12 @@ public:
|
|||
}
|
||||
|
||||
//==============================================================================
|
||||
void audioDeviceIOCallback (const float* const* /*inputChannelData*/, int /*numInputChannels*/,
|
||||
float* const* outputChannelData, int numOutputChannels,
|
||||
int numSamples) override
|
||||
void audioDeviceIOCallbackWithContext (const float* const* inputChannelData, int numInputChannels,
|
||||
float* const* outputChannelData, int numOutputChannels,
|
||||
int numSamples, const AudioIODeviceCallbackContext& context) override
|
||||
{
|
||||
ignoreUnused (inputChannelData, numInputChannels, context);
|
||||
|
||||
AudioBuffer<float> buffer (outputChannelData, numOutputChannels, numSamples);
|
||||
buffer.clear();
|
||||
|
||||
|
|
|
|||
|
|
@ -1891,10 +1891,19 @@ private:
|
|||
std::function<void()> stopped;
|
||||
std::function<void()> error;
|
||||
|
||||
void audioDeviceIOCallback (const float* const*, int, float* const*, int, int) override { NullCheckedInvocation::invoke (callback); }
|
||||
void audioDeviceAboutToStart (AudioIODevice*) override { NullCheckedInvocation::invoke (aboutToStart); }
|
||||
void audioDeviceStopped() override { NullCheckedInvocation::invoke (stopped); }
|
||||
void audioDeviceError (const String&) override { NullCheckedInvocation::invoke (error); }
|
||||
void audioDeviceIOCallbackWithContext (const float* const*,
|
||||
int,
|
||||
float* const*,
|
||||
int,
|
||||
int,
|
||||
const AudioIODeviceCallbackContext&) override
|
||||
{
|
||||
NullCheckedInvocation::invoke (callback);
|
||||
}
|
||||
|
||||
void audioDeviceAboutToStart (AudioIODevice*) override { NullCheckedInvocation::invoke (aboutToStart); }
|
||||
void audioDeviceStopped() override { NullCheckedInvocation::invoke (stopped); }
|
||||
void audioDeviceError (const String&) override { NullCheckedInvocation::invoke (error); }
|
||||
};
|
||||
|
||||
void initialiseManager (AudioDeviceManager& manager)
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ struct AudioIODeviceCallbackContext
|
|||
One of these is passed to an AudioIODevice object to stream the audio data
|
||||
in and out.
|
||||
|
||||
The AudioIODevice will repeatedly call this class's audioDeviceIOCallback()
|
||||
The AudioIODevice will repeatedly call this class's audioDeviceIOCallbackWithContext()
|
||||
method on its own high-priority audio thread, when it needs to send or receive
|
||||
the next block of data.
|
||||
|
||||
|
|
@ -90,20 +90,8 @@ public:
|
|||
processing into several smaller callbacks to ensure higher audio
|
||||
performance. So make sure your code can cope with reasonable
|
||||
changes in the buffer size from one callback to the next.
|
||||
*/
|
||||
virtual void audioDeviceIOCallback (const float* const* inputChannelData,
|
||||
int numInputChannels,
|
||||
float* const* outputChannelData,
|
||||
int numOutputChannels,
|
||||
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.
|
||||
@param context Additional information that may be passed to the
|
||||
AudioIODeviceCallback.
|
||||
*/
|
||||
virtual void audioDeviceIOCallbackWithContext (const float* const* inputChannelData,
|
||||
int numInputChannels,
|
||||
|
|
@ -112,8 +100,7 @@ public:
|
|||
int numSamples,
|
||||
const AudioIODeviceCallbackContext& context)
|
||||
{
|
||||
audioDeviceIOCallback (inputChannelData, numInputChannels, outputChannelData, numOutputChannels, numSamples);
|
||||
ignoreUnused (context);
|
||||
ignoreUnused (inputChannelData, numInputChannels, outputChannelData, numOutputChannels, numSamples, context);
|
||||
}
|
||||
|
||||
/** Called to indicate that the device is about to start calling back.
|
||||
|
|
|
|||
|
|
@ -56,12 +56,15 @@ void AudioSourcePlayer::setGain (const float newGain) noexcept
|
|||
gain = newGain;
|
||||
}
|
||||
|
||||
void AudioSourcePlayer::audioDeviceIOCallback (const float* const* inputChannelData,
|
||||
int totalNumInputChannels,
|
||||
float* const* outputChannelData,
|
||||
int totalNumOutputChannels,
|
||||
int numSamples)
|
||||
void AudioSourcePlayer::audioDeviceIOCallbackWithContext (const float* const* inputChannelData,
|
||||
int totalNumInputChannels,
|
||||
float* const* outputChannelData,
|
||||
int totalNumOutputChannels,
|
||||
int numSamples,
|
||||
const AudioIODeviceCallbackContext& context)
|
||||
{
|
||||
ignoreUnused (context);
|
||||
|
||||
// these should have been prepared by audioDeviceAboutToStart()...
|
||||
jassert (sampleRate > 0 && bufferSize > 0);
|
||||
|
||||
|
|
|
|||
|
|
@ -79,12 +79,13 @@ public:
|
|||
float getGain() const noexcept { return gain; }
|
||||
|
||||
//==============================================================================
|
||||
/** Implementation of the AudioIODeviceCallback method. */
|
||||
void audioDeviceIOCallback (const float* const* inputChannelData,
|
||||
int totalNumInputChannels,
|
||||
float* const* outputChannelData,
|
||||
int totalNumOutputChannels,
|
||||
int numSamples) override;
|
||||
/** Implementation of the AudioIODeviceCallbackWithContext method. */
|
||||
void audioDeviceIOCallbackWithContext (const float* const* inputChannelData,
|
||||
int totalNumInputChannels,
|
||||
float* const* outputChannelData,
|
||||
int totalNumOutputChannels,
|
||||
int numSamples,
|
||||
const AudioIODeviceCallbackContext& context) override;
|
||||
|
||||
/** Implementation of the AudioIODeviceCallback method. */
|
||||
void audioDeviceAboutToStart (AudioIODevice* device) override;
|
||||
|
|
|
|||
|
|
@ -425,7 +425,7 @@ private:
|
|||
|
||||
On some platforms (such as iOS 10), the expected buffer size reported in
|
||||
audioDeviceAboutToStart may be smaller than the blocks passed to
|
||||
audioDeviceIOCallback. This can lead to out-of-bounds reads if the render
|
||||
audioDeviceIOCallbackWithContext. This can lead to out-of-bounds reads if the render
|
||||
callback depends on additional buffers which were initialised using the
|
||||
smaller size.
|
||||
|
||||
|
|
|
|||
|
|
@ -242,15 +242,16 @@ void SoundPlayer::playTestSound()
|
|||
}
|
||||
|
||||
//==============================================================================
|
||||
void SoundPlayer::audioDeviceIOCallback (const float* const* inputChannelData,
|
||||
int numInputChannels,
|
||||
float* const* outputChannelData,
|
||||
int numOutputChannels,
|
||||
int numSamples)
|
||||
void SoundPlayer::audioDeviceIOCallbackWithContext (const float* const* inputChannelData,
|
||||
int numInputChannels,
|
||||
float* const* outputChannelData,
|
||||
int numOutputChannels,
|
||||
int numSamples,
|
||||
const AudioIODeviceCallbackContext& context)
|
||||
{
|
||||
player.audioDeviceIOCallback (inputChannelData, numInputChannels,
|
||||
outputChannelData, numOutputChannels,
|
||||
numSamples);
|
||||
player.audioDeviceIOCallbackWithContext (inputChannelData, numInputChannels,
|
||||
outputChannelData, numOutputChannels,
|
||||
numSamples, context);
|
||||
}
|
||||
|
||||
void SoundPlayer::audioDeviceAboutToStart (AudioIODevice* device)
|
||||
|
|
|
|||
|
|
@ -110,7 +110,7 @@ public:
|
|||
|
||||
//==============================================================================
|
||||
/** @internal */
|
||||
void audioDeviceIOCallback (const float* const*, int, float* const*, int, int) override;
|
||||
void audioDeviceIOCallbackWithContext (const float* const*, int, float* const*, int, int, const AudioIODeviceCallbackContext&) override;
|
||||
/** @internal */
|
||||
void audioDeviceAboutToStart (AudioIODevice*) override;
|
||||
/** @internal */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue