upgrade to JUCE 5.4.3. Remove (probably) unused JUCE modules. Remove VST2 target (it's been end-of-life'd by Steinberg and by JUCE)
This commit is contained in:
@ -23,14 +23,6 @@
|
||||
namespace juce
|
||||
{
|
||||
|
||||
AudioDeviceManager::AudioDeviceSetup::AudioDeviceSetup()
|
||||
: sampleRate (0),
|
||||
bufferSize (0),
|
||||
useDefaultInputChannels (true),
|
||||
useDefaultOutputChannels (true)
|
||||
{
|
||||
}
|
||||
|
||||
bool AudioDeviceManager::AudioDeviceSetup::operator== (const AudioDeviceManager::AudioDeviceSetup& other) const
|
||||
{
|
||||
return outputDeviceName == other.outputDeviceName
|
||||
@ -132,10 +124,36 @@ void AudioDeviceManager::audioDeviceListChanged()
|
||||
{
|
||||
if (currentAudioDevice != nullptr)
|
||||
{
|
||||
currentSetup.sampleRate = currentAudioDevice->getCurrentSampleRate();
|
||||
currentSetup.bufferSize = currentAudioDevice->getCurrentBufferSizeSamples();
|
||||
currentSetup.inputChannels = currentAudioDevice->getActiveInputChannels();
|
||||
currentSetup.outputChannels = currentAudioDevice->getActiveOutputChannels();
|
||||
auto isCurrentDeviceStillAvailable = [&]
|
||||
{
|
||||
for (auto* dt : availableDeviceTypes)
|
||||
if (currentAudioDevice->getTypeName() == dt->getTypeName())
|
||||
for (auto& dn : dt->getDeviceNames())
|
||||
if (currentAudioDevice->getName() == dn)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
};
|
||||
|
||||
if (! isCurrentDeviceStillAvailable())
|
||||
{
|
||||
closeAudioDevice();
|
||||
|
||||
std::unique_ptr<XmlElement> e (createStateXml());
|
||||
|
||||
if (e == nullptr)
|
||||
initialiseDefault (preferredDeviceName, ¤tSetup);
|
||||
else
|
||||
initialiseFromXML (*e, true, preferredDeviceName, ¤tSetup);
|
||||
}
|
||||
|
||||
if (currentAudioDevice != nullptr)
|
||||
{
|
||||
currentSetup.sampleRate = currentAudioDevice->getCurrentSampleRate();
|
||||
currentSetup.bufferSize = currentAudioDevice->getCurrentBufferSizeSamples();
|
||||
currentSetup.inputChannels = currentAudioDevice->getActiveInputChannels();
|
||||
currentSetup.outputChannels = currentAudioDevice->getActiveOutputChannels();
|
||||
}
|
||||
}
|
||||
|
||||
sendChangeMessage();
|
||||
@ -197,12 +215,13 @@ String AudioDeviceManager::initialise (const int numInputChannelsNeeded,
|
||||
|
||||
numInputChansNeeded = numInputChannelsNeeded;
|
||||
numOutputChansNeeded = numOutputChannelsNeeded;
|
||||
preferredDeviceName = preferredDefaultDeviceName;
|
||||
|
||||
if (xml != nullptr && xml->hasTagName ("DEVICESETUP"))
|
||||
return initialiseFromXML (*xml, selectDefaultDeviceOnFailure,
|
||||
preferredDefaultDeviceName, preferredSetupOptions);
|
||||
preferredDeviceName, preferredSetupOptions);
|
||||
|
||||
return initialiseDefault (preferredDefaultDeviceName, preferredSetupOptions);
|
||||
return initialiseDefault (preferredDeviceName, preferredSetupOptions);
|
||||
}
|
||||
|
||||
String AudioDeviceManager::initialiseDefault (const String& preferredDefaultDeviceName,
|
||||
@ -367,6 +386,11 @@ AudioIODeviceType* AudioDeviceManager::findType (const String& inputName, const
|
||||
return {};
|
||||
}
|
||||
|
||||
AudioDeviceManager::AudioDeviceSetup AudioDeviceManager::getAudioDeviceSetup() const
|
||||
{
|
||||
return currentSetup;
|
||||
}
|
||||
|
||||
void AudioDeviceManager::getAudioDeviceSetup (AudioDeviceSetup& setup) const
|
||||
{
|
||||
setup = currentSetup;
|
||||
@ -428,16 +452,15 @@ String AudioDeviceManager::setAudioDeviceSetup (const AudioDeviceSetup& newSetup
|
||||
|
||||
stopDevice();
|
||||
|
||||
if (! newSetup.useDefaultInputChannels) numInputChansNeeded = newSetup.inputChannels.countNumberOfSetBits();
|
||||
if (! newSetup.useDefaultOutputChannels) numOutputChansNeeded = newSetup.outputChannels.countNumberOfSetBits();
|
||||
if (! newSetup.useDefaultInputChannels)
|
||||
numInputChansNeeded = newSetup.inputChannels.countNumberOfSetBits();
|
||||
|
||||
auto newInputDeviceName (numInputChansNeeded == 0 ? String() : newSetup.inputDeviceName);
|
||||
auto newOutputDeviceName (numOutputChansNeeded == 0 ? String() : newSetup.outputDeviceName);
|
||||
if (! newSetup.useDefaultOutputChannels)
|
||||
numOutputChansNeeded = newSetup.outputChannels.countNumberOfSetBits();
|
||||
|
||||
String error;
|
||||
auto* type = getCurrentDeviceTypeObject();
|
||||
|
||||
if (type == nullptr || (newInputDeviceName.isEmpty() && newOutputDeviceName.isEmpty()))
|
||||
if (type == nullptr)
|
||||
{
|
||||
deleteCurrentDevice();
|
||||
|
||||
@ -447,20 +470,22 @@ String AudioDeviceManager::setAudioDeviceSetup (const AudioDeviceSetup& newSetup
|
||||
return {};
|
||||
}
|
||||
|
||||
if (currentSetup.inputDeviceName != newInputDeviceName
|
||||
|| currentSetup.outputDeviceName != newOutputDeviceName
|
||||
|| currentAudioDevice == nullptr)
|
||||
String error;
|
||||
|
||||
if (currentSetup.inputDeviceName != newSetup.inputDeviceName
|
||||
|| currentSetup.outputDeviceName != newSetup.outputDeviceName
|
||||
|| currentAudioDevice == nullptr)
|
||||
{
|
||||
deleteCurrentDevice();
|
||||
scanDevicesIfNeeded();
|
||||
|
||||
if (newOutputDeviceName.isNotEmpty() && ! deviceListContains (type, false, newOutputDeviceName))
|
||||
return "No such device: " + newOutputDeviceName;
|
||||
if (newSetup.outputDeviceName.isNotEmpty() && ! deviceListContains (type, false, newSetup.outputDeviceName))
|
||||
return "No such device: " + newSetup.outputDeviceName;
|
||||
|
||||
if (newInputDeviceName.isNotEmpty() && ! deviceListContains (type, true, newInputDeviceName))
|
||||
return "No such device: " + newInputDeviceName;
|
||||
if (newSetup.inputDeviceName.isNotEmpty() && ! deviceListContains (type, true, newSetup.inputDeviceName))
|
||||
return "No such device: " + newSetup.inputDeviceName;
|
||||
|
||||
currentAudioDevice.reset (type->createDevice (newOutputDeviceName, newInputDeviceName));
|
||||
currentAudioDevice.reset (type->createDevice (newSetup.outputDeviceName, newSetup.inputDeviceName));
|
||||
|
||||
if (currentAudioDevice == nullptr)
|
||||
error = "Can't open the audio device!\n\n"
|
||||
@ -487,15 +512,26 @@ String AudioDeviceManager::setAudioDeviceSetup (const AudioDeviceSetup& newSetup
|
||||
outputChannels.setRange (0, numOutputChansNeeded, true);
|
||||
}
|
||||
|
||||
if (newInputDeviceName.isEmpty()) inputChannels.clear();
|
||||
if (newOutputDeviceName.isEmpty()) outputChannels.clear();
|
||||
if (newSetup.inputDeviceName.isEmpty()) inputChannels.clear();
|
||||
if (newSetup.outputDeviceName.isEmpty()) outputChannels.clear();
|
||||
}
|
||||
|
||||
if (! newSetup.useDefaultInputChannels) inputChannels = newSetup.inputChannels;
|
||||
if (! newSetup.useDefaultOutputChannels) outputChannels = newSetup.outputChannels;
|
||||
if (! newSetup.useDefaultInputChannels)
|
||||
inputChannels = newSetup.inputChannels;
|
||||
|
||||
if (! newSetup.useDefaultOutputChannels)
|
||||
outputChannels = newSetup.outputChannels;
|
||||
|
||||
currentSetup = newSetup;
|
||||
|
||||
if (inputChannels.isZero() && outputChannels.isZero())
|
||||
{
|
||||
if (treatAsChosenDevice)
|
||||
updateXml();
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
currentSetup.sampleRate = chooseBestSampleRate (newSetup.sampleRate);
|
||||
currentSetup.bufferSize = chooseBestBufferSize (newSetup.bufferSize);
|
||||
|
||||
@ -582,7 +618,7 @@ void AudioDeviceManager::closeAudioDevice()
|
||||
{
|
||||
stopDevice();
|
||||
currentAudioDevice.reset();
|
||||
cpuUsageMs = 0;
|
||||
loadMeasurer.reset();
|
||||
}
|
||||
|
||||
void AudioDeviceManager::restartLastAudioDevice()
|
||||
@ -694,7 +730,7 @@ void AudioDeviceManager::audioDeviceIOCallbackInt (const float** inputChannelDat
|
||||
|
||||
if (callbacks.size() > 0)
|
||||
{
|
||||
auto callbackStartTime = Time::getMillisecondCounterHiRes();
|
||||
AudioProcessLoadMeasurer::ScopedTimer timer (loadMeasurer);
|
||||
|
||||
tempBuffer.setSize (jmax (1, numOutputChannels), jmax (1, numSamples), false, false, true);
|
||||
|
||||
@ -716,13 +752,6 @@ void AudioDeviceManager::audioDeviceIOCallbackInt (const float** inputChannelDat
|
||||
dst[j] += src[j];
|
||||
}
|
||||
}
|
||||
|
||||
auto msTaken = Time::getMillisecondCounterHiRes() - callbackStartTime;
|
||||
const double filterAmount = 0.2;
|
||||
cpuUsageMs += filterAmount * (msTaken - cpuUsageMs);
|
||||
|
||||
if (msTaken > msPerBlock)
|
||||
++xruns;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -748,17 +777,8 @@ void AudioDeviceManager::audioDeviceIOCallbackInt (const float** inputChannelDat
|
||||
|
||||
void AudioDeviceManager::audioDeviceAboutToStartInt (AudioIODevice* const device)
|
||||
{
|
||||
cpuUsageMs = 0;
|
||||
xruns = 0;
|
||||
|
||||
auto sampleRate = device->getCurrentSampleRate();
|
||||
auto blockSize = device->getCurrentBufferSizeSamples();
|
||||
|
||||
if (sampleRate > 0.0 && blockSize > 0)
|
||||
{
|
||||
msPerBlock = 1000.0 * blockSize / sampleRate;
|
||||
timeToCpuScale = (msPerBlock > 0.0) ? (1.0 / msPerBlock) : 0.0;
|
||||
}
|
||||
loadMeasurer.reset (device->getCurrentSampleRate(),
|
||||
device->getCurrentBufferSizeSamples());
|
||||
|
||||
{
|
||||
const ScopedLock sl (audioCallbackLock);
|
||||
@ -772,13 +792,12 @@ void AudioDeviceManager::audioDeviceAboutToStartInt (AudioIODevice* const device
|
||||
|
||||
void AudioDeviceManager::audioDeviceStoppedInt()
|
||||
{
|
||||
cpuUsageMs = 0;
|
||||
timeToCpuScale = 0;
|
||||
xruns = 0;
|
||||
sendChangeMessage();
|
||||
|
||||
const ScopedLock sl (audioCallbackLock);
|
||||
|
||||
loadMeasurer.reset();
|
||||
|
||||
for (int i = callbacks.size(); --i >= 0;)
|
||||
callbacks.getUnchecked(i)->audioDeviceStopped();
|
||||
}
|
||||
@ -793,7 +812,7 @@ void AudioDeviceManager::audioDeviceErrorInt (const String& message)
|
||||
|
||||
double AudioDeviceManager::getCpuUsage() const
|
||||
{
|
||||
return jlimit (0.0, 1.0, timeToCpuScale * cpuUsageMs);
|
||||
return loadMeasurer.getLoadAsProportion();
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
@ -980,7 +999,7 @@ void AudioDeviceManager::playTestSound()
|
||||
|
||||
auto phasePerSample = MathConstants<double>::twoPi / (sampleRate / frequency);
|
||||
|
||||
auto* newSound = new AudioBuffer<float> (1, soundLength);
|
||||
std::unique_ptr<AudioBuffer<float>> newSound (new AudioBuffer<float> (1, soundLength));
|
||||
|
||||
for (int i = 0; i < soundLength; ++i)
|
||||
newSound->setSample (0, i, amplitude * (float) std::sin (i * phasePerSample));
|
||||
@ -988,15 +1007,17 @@ void AudioDeviceManager::playTestSound()
|
||||
newSound->applyGainRamp (0, 0, soundLength / 10, 0.0f, 1.0f);
|
||||
newSound->applyGainRamp (0, soundLength - soundLength / 4, soundLength / 4, 1.0f, 0.0f);
|
||||
|
||||
const ScopedLock sl (audioCallbackLock);
|
||||
testSound.reset (newSound);
|
||||
{
|
||||
const ScopedLock sl (audioCallbackLock);
|
||||
std::swap (testSound, newSound);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int AudioDeviceManager::getXRunCount() const noexcept
|
||||
{
|
||||
auto deviceXRuns = (currentAudioDevice != nullptr ? currentAudioDevice->getXRunCount() : -1);
|
||||
return jmax (0, deviceXRuns) + xruns;
|
||||
return jmax (0, deviceXRuns) + loadMeasurer.getXRunCount();
|
||||
}
|
||||
|
||||
} // namespace juce
|
||||
|
@ -76,7 +76,7 @@ public:
|
||||
AudioDeviceManager();
|
||||
|
||||
/** Destructor. */
|
||||
~AudioDeviceManager();
|
||||
~AudioDeviceManager() override;
|
||||
|
||||
//==============================================================================
|
||||
/**
|
||||
@ -89,17 +89,6 @@ public:
|
||||
*/
|
||||
struct JUCE_API AudioDeviceSetup
|
||||
{
|
||||
/** Creates an AudioDeviceSetup object.
|
||||
|
||||
The default constructor sets all the member variables to indicate default values.
|
||||
You can then fill-in any values you want to before passing the object to
|
||||
AudioDeviceManager::initialise().
|
||||
*/
|
||||
AudioDeviceSetup();
|
||||
|
||||
bool operator== (const AudioDeviceSetup& other) const;
|
||||
bool operator!= (const AudioDeviceSetup& other) const;
|
||||
|
||||
/** The name of the audio device used for output.
|
||||
The name has to be one of the ones listed by the AudioDeviceManager's currently
|
||||
selected device type.
|
||||
@ -119,13 +108,13 @@ public:
|
||||
A value of 0 indicates that you don't care what rate is used, and the
|
||||
device will choose a sensible rate for you.
|
||||
*/
|
||||
double sampleRate;
|
||||
double sampleRate = 0;
|
||||
|
||||
/** The buffer size, in samples.
|
||||
This buffer size is used for both the input and output devices.
|
||||
A value of 0 indicates the default buffer size.
|
||||
*/
|
||||
int bufferSize;
|
||||
int bufferSize = 0;
|
||||
|
||||
/** The set of active input channels.
|
||||
The bits that are set in this array indicate the channels of the
|
||||
@ -138,7 +127,7 @@ public:
|
||||
should be ignored, and instead, the device's default channels
|
||||
should be used.
|
||||
*/
|
||||
bool useDefaultInputChannels;
|
||||
bool useDefaultInputChannels = true;
|
||||
|
||||
/** The set of active output channels.
|
||||
The bits that are set in this array indicate the channels of the
|
||||
@ -151,7 +140,10 @@ public:
|
||||
should be ignored, and instead, the device's default channels
|
||||
should be used.
|
||||
*/
|
||||
bool useDefaultOutputChannels;
|
||||
bool useDefaultOutputChannels = true;
|
||||
|
||||
bool operator== (const AudioDeviceSetup&) const;
|
||||
bool operator!= (const AudioDeviceSetup&) const;
|
||||
};
|
||||
|
||||
|
||||
@ -211,6 +203,13 @@ public:
|
||||
/** Returns the current device properties that are in use.
|
||||
@see setAudioDeviceSetup
|
||||
*/
|
||||
AudioDeviceSetup getAudioDeviceSetup() const;
|
||||
|
||||
/** Returns the current device properties that are in use.
|
||||
This is an old method, kept around for compatibility, but you should prefer the new
|
||||
version which returns the result rather than taking an out-parameter.
|
||||
@see getAudioDeviceSetup()
|
||||
*/
|
||||
void getAudioDeviceSetup (AudioDeviceSetup& result) const;
|
||||
|
||||
/** Changes the current device or its settings.
|
||||
@ -232,8 +231,7 @@ public:
|
||||
|
||||
@see getAudioDeviceSetup
|
||||
*/
|
||||
String setAudioDeviceSetup (const AudioDeviceSetup& newSetup,
|
||||
bool treatAsChosenDevice);
|
||||
String setAudioDeviceSetup (const AudioDeviceSetup& newSetup, bool treatAsChosenDevice);
|
||||
|
||||
|
||||
/** Returns the currently-active audio device. */
|
||||
@ -257,8 +255,7 @@ public:
|
||||
|
||||
For a list of types, see getAvailableDeviceTypes().
|
||||
*/
|
||||
void setCurrentAudioDeviceType (const String& type,
|
||||
bool treatAsChosenDevice);
|
||||
void setCurrentAudioDeviceType (const String& type, bool treatAsChosenDevice);
|
||||
|
||||
/** Closes the currently-open device.
|
||||
You can call restartLastAudioDevice() later to reopen it in the same state
|
||||
@ -435,10 +432,10 @@ public:
|
||||
*/
|
||||
LevelMeter::Ptr getInputLevelGetter() noexcept { return inputLevelGetter; }
|
||||
|
||||
/** Returns a reference-counted object that can be used to get the current input level.
|
||||
/** Returns a reference-counted object that can be used to get the current output level.
|
||||
|
||||
You need to store this object locally to ensure that the reference count is incremented
|
||||
and decremented properly. The current input level value can be read using getCurrentLevel().
|
||||
and decremented properly. The current output level value can be read using getCurrentLevel().
|
||||
*/
|
||||
LevelMeter::Ptr getOutputLevelGetter() noexcept { return outputLevelGetter; }
|
||||
|
||||
@ -473,7 +470,7 @@ private:
|
||||
std::unique_ptr<AudioIODevice> currentAudioDevice;
|
||||
Array<AudioIODeviceCallback*> callbacks;
|
||||
int numInputChansNeeded = 0, numOutputChansNeeded = 2;
|
||||
String currentDeviceType;
|
||||
String preferredDeviceName, currentDeviceType;
|
||||
BigInteger inputChannels, outputChannels;
|
||||
std::unique_ptr<XmlElement> lastExplicitSettings;
|
||||
mutable bool listNeedsScanning = true;
|
||||
@ -496,16 +493,13 @@ private:
|
||||
std::unique_ptr<AudioBuffer<float>> testSound;
|
||||
int testSoundPosition = 0;
|
||||
|
||||
double cpuUsageMs = 0, timeToCpuScale = 0, msPerBlock = 0;
|
||||
int xruns = 0;
|
||||
AudioProcessLoadMeasurer loadMeasurer;
|
||||
|
||||
LevelMeter::Ptr inputLevelGetter { new LevelMeter() },
|
||||
outputLevelGetter { new LevelMeter() };
|
||||
|
||||
//==============================================================================
|
||||
class CallbackHandler;
|
||||
friend class CallbackHandler;
|
||||
friend struct ContainerDeletePolicy<CallbackHandler>;
|
||||
std::unique_ptr<CallbackHandler> callbackHandler;
|
||||
|
||||
void audioDeviceIOCallbackInt (const float** inputChannelData, int totalNumInputChannels,
|
||||
|
@ -43,7 +43,7 @@ class JUCE_API AudioIODeviceCallback
|
||||
{
|
||||
public:
|
||||
/** Destructor. */
|
||||
virtual ~AudioIODeviceCallback() {}
|
||||
virtual ~AudioIODeviceCallback() = default;
|
||||
|
||||
/** Processes a block of incoming and outgoing audio data.
|
||||
|
||||
|
@ -126,7 +126,7 @@ public:
|
||||
class Listener
|
||||
{
|
||||
public:
|
||||
virtual ~Listener() {}
|
||||
virtual ~Listener() = default;
|
||||
|
||||
/** Called when the list of available audio devices changes. */
|
||||
virtual void audioDeviceListChanged() = 0;
|
||||
|
Reference in New Issue
Block a user