1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-16 00:34:19 +00:00

Standalone Plug-In: Added an override flag to not auto open midi devices on mobile

This commit is contained in:
hogliux 2017-10-26 12:18:15 +01:00
parent 00af141203
commit 0b2822f819
2 changed files with 27 additions and 18 deletions

View file

@ -87,6 +87,11 @@ public:
false, {}, nullptr
#ifdef JucePlugin_PreferredChannelConfigurations
, juce::Array<StandalonePluginHolder::PluginInOuts> (channels, juce::numElementsInArray (channels))
#else
, {}
#endif
#if JUCE_DONT_AUTO_OPEN_MIDI_DEVICES_ON_MOBILE
, false
#endif
);
}

View file

@ -35,10 +35,8 @@ namespace juce
function that the other plugin wrappers use, and will run it through the
computer's audio/MIDI devices using AudioDeviceManager and AudioProcessorPlayer.
*/
class StandalonePluginHolder : private AudioIODeviceCallback
#if JUCE_IOS || JUCE_ANDROID
, Timer
#endif
class StandalonePluginHolder : private AudioIODeviceCallback,
private Timer
{
public:
//==============================================================================
@ -63,11 +61,18 @@ public:
bool takeOwnershipOfSettings = true,
const String& preferredDefaultDeviceName = String(),
const AudioDeviceManager::AudioDeviceSetup* preferredSetupOptions = nullptr,
const Array<PluginInOuts>& channels = Array<PluginInOuts>())
const Array<PluginInOuts>& channels = Array<PluginInOuts>(),
#if JUCE_ANDROID || JUCE_IOS
bool shouldAutoOpenMidiDevices = true
#else
bool shouldAutoOpenMidiDevices = false
#endif
)
: settings (settingsToUse, takeOwnershipOfSettings),
channelConfiguration (channels),
shouldMuteInput (! isInterAppAudioConnected())
shouldMuteInput (! isInterAppAudioConnected()),
autoOpenMidiDevices (shouldAutoOpenMidiDevices)
{
createPlugin();
@ -91,16 +96,13 @@ public:
reloadPluginState();
startPlaying();
#if JUCE_IOS || JUCE_ANDROID
startTimer (500);
#endif
if (autoOpenMidiDevices)
startTimer (500);
}
virtual ~StandalonePluginHolder()
{
#if JUCE_IOS || JUCE_ANDROID
stopTimer();
#endif
deletePlugin();
shutDownAudioDevices();
@ -383,12 +385,10 @@ public:
bool processorHasPotentialFeedbackLoop = true;
Value shouldMuteInput;
AudioSampleBuffer emptyBuffer;
bool autoOpenMidiDevices;
ScopedPointer<AudioDeviceManager::AudioDeviceSetup> options;
#if JUCE_IOS || JUCE_ANDROID
StringArray lastMidiDevices;
#endif
private:
//==============================================================================
@ -513,7 +513,6 @@ private:
deviceManager.removeAudioCallback (this);
}
#if JUCE_IOS || JUCE_ANDROID
void timerCallback() override
{
auto newMidiDevices = MidiInput::getDevices();
@ -529,7 +528,6 @@ private:
deviceManager.setMidiInputEnabled (newDevice, true);
}
}
#endif
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (StandalonePluginHolder)
};
@ -561,7 +559,13 @@ public:
bool takeOwnershipOfSettings,
const String& preferredDefaultDeviceName = String(),
const AudioDeviceManager::AudioDeviceSetup* preferredSetupOptions = nullptr,
const Array<PluginInOuts>& constrainToConfiguration = Array<PluginInOuts> ())
const Array<PluginInOuts>& constrainToConfiguration = Array<PluginInOuts> (),
#if JUCE_ANDROID || JUCE_IOS
bool autoOpenMidiDevices = true
#else
bool autoOpenMidiDevices = false
#endif
)
: DocumentWindow (title, backgroundColour, DocumentWindow::minimiseButton | DocumentWindow::closeButton),
optionsButton ("Options")
{
@ -573,7 +577,7 @@ public:
pluginHolder = new StandalonePluginHolder (settingsToUse, takeOwnershipOfSettings,
preferredDefaultDeviceName, preferredSetupOptions,
constrainToConfiguration);
constrainToConfiguration, autoOpenMidiDevices);
#if JUCE_IOS || JUCE_ANDROID
setFullScreen (true);