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:
Alex Birch
2019-06-22 20:41:38 +01:00
parent d22c2cd4fa
commit 9ee566b251
1140 changed files with 67534 additions and 105952 deletions

View File

@ -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, &currentSetup);
else
initialiseFromXML (*e, true, preferredDeviceName, &currentSetup);
}
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