From 019fbbb1d94df9a44f436632ceca199b80c1e6eb Mon Sep 17 00:00:00 2001 From: jules Date: Sat, 13 Oct 2012 19:42:06 +0100 Subject: [PATCH] Minor AU hosting changes. --- .../juce_AudioUnitPluginFormat.mm | 29 ++++++++++--------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/modules/juce_audio_processors/format_types/juce_AudioUnitPluginFormat.mm b/modules/juce_audio_processors/format_types/juce_AudioUnitPluginFormat.mm index d5787a6dfe..70dd9589c2 100644 --- a/modules/juce_audio_processors/format_types/juce_AudioUnitPluginFormat.mm +++ b/modules/juce_audio_processors/format_types/juce_AudioUnitPluginFormat.mm @@ -303,7 +303,7 @@ public: audioUnit = (AudioUnit) OpenComponent (comp); wantsMidiMessages = componentDesc.componentType == kAudioUnitType_MusicDevice - || componentDesc.componentType == kAudioUnitType_MusicEffect; + || componentDesc.componentType == kAudioUnitType_MusicEffect; } } @@ -323,7 +323,9 @@ public: if (audioUnit != 0) { - AudioUnitUninitialize (audioUnit); + if (prepared) + releaseResources(); + CloseComponent (audioUnit); audioUnit = 0; } @@ -450,6 +452,7 @@ public: wasPlaying = false; prepared = (AudioUnitInitialize (audioUnit) == noErr); + jassert (prepared); } } @@ -1165,9 +1168,9 @@ class AudioUnitPluginWindowCocoa : public AudioProcessorEditor, public Timer { public: - AudioUnitPluginWindowCocoa (AudioUnitPluginInstance& plugin_, const bool createGenericViewIfNeeded) - : AudioProcessorEditor (&plugin_), - plugin (plugin_) + AudioUnitPluginWindowCocoa (AudioUnitPluginInstance& p, const bool createGenericViewIfNeeded) + : AudioProcessorEditor (&p), + plugin (p) { addAndMakeVisible (&wrapper); @@ -1180,15 +1183,13 @@ public: ~AudioUnitPluginWindowCocoa() { - const bool wasValid = isValid(); - - // NB: making the wrapper invisible before removing it causes - // strange internal crashes in some Apple AUs. - removeChildComponent (&wrapper); - wrapper.setView (nil); - - if (wasValid) + if (isValid()) + { + wrapper.setVisible (false); + removeChildComponent (&wrapper); + wrapper.setView (nil); plugin.editorBeingDeleted (this); + } } bool isValid() const { return wrapper.getView() != nil; } @@ -1262,7 +1263,7 @@ private: } } - if (createGenericViewIfNeeded && (pluginView == 0)) + if (createGenericViewIfNeeded && (pluginView == nil)) { { // This forces CoreAudio.component to be loaded, otherwise the AUGenericView will assert