From 0b2822f819f3e99df6855272ef6ea2fbae31fc99 Mon Sep 17 00:00:00 2001 From: hogliux Date: Thu, 26 Oct 2017 12:18:15 +0100 Subject: [PATCH] Standalone Plug-In: Added an override flag to not auto open midi devices on mobile --- .../Standalone/juce_StandaloneFilterApp.cpp | 5 +++ .../Standalone/juce_StandaloneFilterWindow.h | 40 ++++++++++--------- 2 files changed, 27 insertions(+), 18 deletions(-) diff --git a/modules/juce_audio_plugin_client/Standalone/juce_StandaloneFilterApp.cpp b/modules/juce_audio_plugin_client/Standalone/juce_StandaloneFilterApp.cpp index 866c02afeb..3e2c0057d2 100644 --- a/modules/juce_audio_plugin_client/Standalone/juce_StandaloneFilterApp.cpp +++ b/modules/juce_audio_plugin_client/Standalone/juce_StandaloneFilterApp.cpp @@ -87,6 +87,11 @@ public: false, {}, nullptr #ifdef JucePlugin_PreferredChannelConfigurations , juce::Array (channels, juce::numElementsInArray (channels)) + #else + , {} + #endif + #if JUCE_DONT_AUTO_OPEN_MIDI_DEVICES_ON_MOBILE + , false #endif ); } diff --git a/modules/juce_audio_plugin_client/Standalone/juce_StandaloneFilterWindow.h b/modules/juce_audio_plugin_client/Standalone/juce_StandaloneFilterWindow.h index 796db380d4..8af8f849a8 100644 --- a/modules/juce_audio_plugin_client/Standalone/juce_StandaloneFilterWindow.h +++ b/modules/juce_audio_plugin_client/Standalone/juce_StandaloneFilterWindow.h @@ -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& channels = Array()) + const Array& channels = Array(), + #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 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& constrainToConfiguration = Array ()) + const Array& constrainToConfiguration = Array (), + #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);