The JUCE cross-platform C++ framework, with DISTRHO/KXStudio specific changes
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1405 lines
49KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library - "Jules' Utility Class Extensions"
  4. Copyright 2004-11 by Raw Material Software Ltd.
  5. ------------------------------------------------------------------------------
  6. JUCE can be redistributed and/or modified under the terms of the GNU General
  7. Public License (Version 2), as published by the Free Software Foundation.
  8. A copy of the license is included in the JUCE distribution, or can be found
  9. online at www.gnu.org/licenses.
  10. JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
  11. WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  12. A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  13. ------------------------------------------------------------------------------
  14. To release a closed-source product which uses JUCE, commercial licenses are
  15. available: visit www.rawmaterialsoftware.com/juce for more information.
  16. ==============================================================================
  17. */
  18. // Your project must contain an AppConfig.h file with your project-specific settings in it,
  19. // and your header search path must make it accessible to the module's files.
  20. #include "AppConfig.h"
  21. #include "../utility/juce_CheckSettingMacros.h"
  22. #if JucePlugin_Build_AU
  23. #if __LP64__
  24. #undef JUCE_SUPPORT_CARBON
  25. #define JUCE_SUPPORT_CARBON 0
  26. #endif
  27. #include "../utility/juce_IncludeSystemHeaders.h"
  28. #include <AudioUnit/AUCocoaUIView.h>
  29. #include <AudioUnit/AudioUnit.h>
  30. #include <AudioToolbox/AudioUnitUtilities.h>
  31. #if JUCE_SUPPORT_CARBON
  32. #define Point CarbonDummyPointName
  33. #define Component CarbonDummyCompName
  34. #endif
  35. #include "AUMIDIEffectBase.h"
  36. #include "MusicDeviceBase.h"
  37. #undef Point
  38. #undef Component
  39. /** The BUILD_AU_CARBON_UI flag lets you specify whether old-school carbon hosts are supported as
  40. well as ones that can open a cocoa view. If this is enabled, you'll need to also add the AUCarbonBase
  41. files to your project.
  42. */
  43. #if ! (defined (BUILD_AU_CARBON_UI) || JUCE_64BIT)
  44. #define BUILD_AU_CARBON_UI 1
  45. #endif
  46. #ifdef __LP64__
  47. #undef BUILD_AU_CARBON_UI // (not possible in a 64-bit build)
  48. #endif
  49. #if BUILD_AU_CARBON_UI
  50. #undef Button
  51. #define Point CarbonDummyPointName
  52. #include "AUCarbonViewBase.h"
  53. #undef Point
  54. class JuceAUView;
  55. #endif
  56. #define JUCE_MAC_WINDOW_VISIBITY_BODGE 1
  57. #include "../utility/juce_IncludeModuleHeaders.h"
  58. #include "../utility/juce_FakeMouseMoveGenerator.h"
  59. #include "../utility/juce_CarbonVisibility.h"
  60. #include "../utility/juce_PluginHostType.h"
  61. #include "../../juce_core/native/juce_osx_ObjCHelpers.h"
  62. //==============================================================================
  63. #define JuceUICreationClass JucePlugin_AUCocoaViewClassName
  64. #define juceFilterObjectPropertyID 0x1a45ffe9
  65. static Array<void*> activePlugins, activeUIs;
  66. static const short channelConfigs[][2] = { JucePlugin_PreferredChannelConfigurations };
  67. static const int numChannelConfigs = sizeof (channelConfigs) / sizeof (*channelConfigs);
  68. #if JucePlugin_IsSynth
  69. #define JuceAUBaseClass MusicDeviceBase
  70. #else
  71. #define JuceAUBaseClass AUMIDIEffectBase
  72. #endif
  73. //==============================================================================
  74. /** Somewhere in the codebase of your plugin, you need to implement this function
  75. and make it create an instance of the filter subclass that you're building.
  76. */
  77. extern AudioProcessor* JUCE_CALLTYPE createPluginFilter();
  78. //==============================================================================
  79. class JuceAU : public JuceAUBaseClass,
  80. public AudioProcessorListener,
  81. public AudioPlayHead,
  82. public ComponentListener
  83. {
  84. public:
  85. //==============================================================================
  86. JuceAU (AudioUnit component)
  87. #if JucePlugin_IsSynth
  88. : MusicDeviceBase (component, 0, 1),
  89. #else
  90. : AUMIDIEffectBase (component),
  91. #endif
  92. bufferSpace (2, 16),
  93. prepared (false)
  94. {
  95. if (activePlugins.size() + activeUIs.size() == 0)
  96. {
  97. #if BUILD_AU_CARBON_UI
  98. NSApplicationLoad();
  99. #endif
  100. initialiseJuce_GUI();
  101. }
  102. juceFilter = createPluginFilter();
  103. jassert (juceFilter != nullptr);
  104. juceFilter->setPlayHead (this);
  105. juceFilter->addListener (this);
  106. Globals()->UseIndexedParameters (juceFilter->getNumParameters());
  107. activePlugins.add (this);
  108. zerostruct (auEvent);
  109. auEvent.mArgument.mParameter.mAudioUnit = GetComponentInstance();
  110. auEvent.mArgument.mParameter.mScope = kAudioUnitScope_Global;
  111. auEvent.mArgument.mParameter.mElement = 0;
  112. CreateElements();
  113. CAStreamBasicDescription streamDescription;
  114. streamDescription.mSampleRate = GetSampleRate();
  115. streamDescription.SetCanonical (channelConfigs[0][1], false);
  116. Outputs().GetIOElement(0)->SetStreamFormat (streamDescription);
  117. #if ! JucePlugin_IsSynth
  118. streamDescription.SetCanonical (channelConfigs[0][0], false);
  119. Inputs().GetIOElement(0)->SetStreamFormat (streamDescription);
  120. #endif
  121. }
  122. ~JuceAU()
  123. {
  124. deleteActiveEditors();
  125. juceFilter = nullptr;
  126. jassert (activePlugins.contains (this));
  127. activePlugins.removeValue (this);
  128. if (activePlugins.size() + activeUIs.size() == 0)
  129. shutdownJuce_GUI();
  130. }
  131. void deleteActiveEditors();
  132. //==============================================================================
  133. ComponentResult GetPropertyInfo (AudioUnitPropertyID inID,
  134. AudioUnitScope inScope,
  135. AudioUnitElement inElement,
  136. UInt32& outDataSize,
  137. Boolean& outWritable)
  138. {
  139. if (inScope == kAudioUnitScope_Global)
  140. {
  141. if (inID == juceFilterObjectPropertyID)
  142. {
  143. outWritable = false;
  144. outDataSize = sizeof (void*) * 2;
  145. return noErr;
  146. }
  147. else if (inID == kAudioUnitProperty_OfflineRender)
  148. {
  149. outWritable = true;
  150. outDataSize = sizeof (UInt32);
  151. return noErr;
  152. }
  153. else if (inID == kMusicDeviceProperty_InstrumentCount)
  154. {
  155. outDataSize = sizeof (UInt32);
  156. outWritable = false;
  157. return noErr;
  158. }
  159. else if (inID == kAudioUnitProperty_CocoaUI)
  160. {
  161. #if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_5
  162. // (On 10.4, there's a random obj-c dispatching crash when trying to load a cocoa UI)
  163. if (SystemStats::getOSXMinorVersionNumber() > 4)
  164. #endif
  165. {
  166. outDataSize = sizeof (AudioUnitCocoaViewInfo);
  167. outWritable = true;
  168. return noErr;
  169. }
  170. }
  171. }
  172. return JuceAUBaseClass::GetPropertyInfo (inID, inScope, inElement, outDataSize, outWritable);
  173. }
  174. ComponentResult GetProperty (AudioUnitPropertyID inID,
  175. AudioUnitScope inScope,
  176. AudioUnitElement inElement,
  177. void* outData)
  178. {
  179. if (inScope == kAudioUnitScope_Global)
  180. {
  181. if (inID == juceFilterObjectPropertyID)
  182. {
  183. ((void**) outData)[0] = (void*) static_cast <AudioProcessor*> (juceFilter);
  184. ((void**) outData)[1] = (void*) this;
  185. return noErr;
  186. }
  187. else if (inID == kAudioUnitProperty_OfflineRender)
  188. {
  189. *(UInt32*) outData = (juceFilter != nullptr && juceFilter->isNonRealtime()) ? 1 : 0;
  190. return noErr;
  191. }
  192. else if (inID == kMusicDeviceProperty_InstrumentCount)
  193. {
  194. *(UInt32*) outData = 1;
  195. return noErr;
  196. }
  197. else if (inID == kAudioUnitProperty_CocoaUI)
  198. {
  199. #if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_5
  200. // (On 10.4, there's a random obj-c dispatching crash when trying to load a cocoa UI)
  201. if (SystemStats::getOSXMinorVersionNumber() > 4)
  202. #endif
  203. {
  204. JUCE_AUTORELEASEPOOL
  205. AudioUnitCocoaViewInfo* info = (AudioUnitCocoaViewInfo*) outData;
  206. const File bundleFile (File::getSpecialLocation (File::currentApplicationFile));
  207. NSString* bundlePath = [NSString stringWithUTF8String: (const char*) bundleFile.getFullPathName().toUTF8()];
  208. NSBundle* b = [NSBundle bundleWithPath: bundlePath];
  209. info->mCocoaAUViewClass[0] = (CFStringRef) [nsStringLiteral (JUCE_STRINGIFY (JuceUICreationClass)) retain];
  210. info->mCocoaAUViewBundleLocation = (CFURLRef) [[NSURL fileURLWithPath: [b bundlePath]] retain];
  211. return noErr;
  212. }
  213. }
  214. }
  215. return JuceAUBaseClass::GetProperty (inID, inScope, inElement, outData);
  216. }
  217. ComponentResult SetProperty (AudioUnitPropertyID inID,
  218. AudioUnitScope inScope,
  219. AudioUnitElement inElement,
  220. const void* inData,
  221. UInt32 inDataSize)
  222. {
  223. if (inScope == kAudioUnitScope_Global && inID == kAudioUnitProperty_OfflineRender)
  224. {
  225. if (juceFilter != nullptr)
  226. juceFilter->setNonRealtime ((*(UInt32*) inData) != 0);
  227. return noErr;
  228. }
  229. return JuceAUBaseClass::SetProperty (inID, inScope, inElement, inData, inDataSize);
  230. }
  231. ComponentResult SaveState (CFPropertyListRef* outData)
  232. {
  233. ComponentResult err = JuceAUBaseClass::SaveState (outData);
  234. if (err != noErr)
  235. return err;
  236. jassert (CFGetTypeID (*outData) == CFDictionaryGetTypeID());
  237. CFMutableDictionaryRef dict = (CFMutableDictionaryRef) *outData;
  238. if (juceFilter != nullptr)
  239. {
  240. juce::MemoryBlock state;
  241. juceFilter->getCurrentProgramStateInformation (state);
  242. if (state.getSize() > 0)
  243. {
  244. CFDataRef ourState = CFDataCreate (kCFAllocatorDefault, (const UInt8*) state.getData(), state.getSize());
  245. CFDictionarySetValue (dict, CFSTR("jucePluginState"), ourState);
  246. CFRelease (ourState);
  247. }
  248. }
  249. return noErr;
  250. }
  251. ComponentResult RestoreState (CFPropertyListRef inData)
  252. {
  253. ComponentResult err = JuceAUBaseClass::RestoreState (inData);
  254. if (err != noErr)
  255. return err;
  256. if (juceFilter != nullptr)
  257. {
  258. CFDictionaryRef dict = (CFDictionaryRef) inData;
  259. CFDataRef data = 0;
  260. if (CFDictionaryGetValueIfPresent (dict, CFSTR("jucePluginState"), (const void**) &data))
  261. {
  262. if (data != 0)
  263. {
  264. const int numBytes = (int) CFDataGetLength (data);
  265. const juce::uint8* const rawBytes = CFDataGetBytePtr (data);
  266. if (numBytes > 0)
  267. juceFilter->setCurrentProgramStateInformation (rawBytes, numBytes);
  268. }
  269. }
  270. }
  271. return noErr;
  272. }
  273. UInt32 SupportedNumChannels (const AUChannelInfo** outInfo)
  274. {
  275. // If you hit this, then you need to add some configurations to your
  276. // JucePlugin_PreferredChannelConfigurations setting..
  277. jassert (numChannelConfigs > 0);
  278. if (outInfo != nullptr)
  279. {
  280. *outInfo = channelInfo;
  281. for (int i = 0; i < numChannelConfigs; ++i)
  282. {
  283. #if JucePlugin_IsSynth
  284. channelInfo[i].inChannels = 0;
  285. #else
  286. channelInfo[i].inChannels = channelConfigs[i][0];
  287. #endif
  288. channelInfo[i].outChannels = channelConfigs[i][1];
  289. }
  290. }
  291. return numChannelConfigs;
  292. }
  293. //==============================================================================
  294. ComponentResult GetParameterInfo (AudioUnitScope inScope,
  295. AudioUnitParameterID inParameterID,
  296. AudioUnitParameterInfo& outParameterInfo)
  297. {
  298. const int index = (int) inParameterID;
  299. if (inScope == kAudioUnitScope_Global
  300. && juceFilter != nullptr
  301. && index < juceFilter->getNumParameters())
  302. {
  303. outParameterInfo.flags = kAudioUnitParameterFlag_IsWritable
  304. | kAudioUnitParameterFlag_IsReadable
  305. | kAudioUnitParameterFlag_HasCFNameString;
  306. const String name (juceFilter->getParameterName (index));
  307. // set whether the param is automatable (unnamed parameters aren't allowed to be automated)
  308. if (name.isEmpty() || ! juceFilter->isParameterAutomatable (index))
  309. outParameterInfo.flags |= kAudioUnitParameterFlag_NonRealTime;
  310. if (juceFilter->isMetaParameter (index))
  311. outParameterInfo.flags |= kAudioUnitParameterFlag_IsGlobalMeta;
  312. AUBase::FillInParameterName (outParameterInfo, name.toCFString(), false);
  313. outParameterInfo.minValue = 0.0f;
  314. outParameterInfo.maxValue = 1.0f;
  315. outParameterInfo.defaultValue = 0.0f;
  316. outParameterInfo.unit = kAudioUnitParameterUnit_Generic;
  317. return noErr;
  318. }
  319. else
  320. {
  321. return kAudioUnitErr_InvalidParameter;
  322. }
  323. }
  324. ComponentResult GetParameter (AudioUnitParameterID inID,
  325. AudioUnitScope inScope,
  326. AudioUnitElement inElement,
  327. Float32& outValue)
  328. {
  329. if (inScope == kAudioUnitScope_Global && juceFilter != nullptr)
  330. {
  331. outValue = juceFilter->getParameter ((int) inID);
  332. return noErr;
  333. }
  334. return AUBase::GetParameter (inID, inScope, inElement, outValue);
  335. }
  336. ComponentResult SetParameter (AudioUnitParameterID inID,
  337. AudioUnitScope inScope,
  338. AudioUnitElement inElement,
  339. Float32 inValue,
  340. UInt32 inBufferOffsetInFrames)
  341. {
  342. if (inScope == kAudioUnitScope_Global && juceFilter != nullptr)
  343. {
  344. juceFilter->setParameter ((int) inID, inValue);
  345. return noErr;
  346. }
  347. return AUBase::SetParameter (inID, inScope, inElement, inValue, inBufferOffsetInFrames);
  348. }
  349. //==============================================================================
  350. ComponentResult Version() { return JucePlugin_VersionCode; }
  351. bool SupportsTail() { return true; }
  352. Float64 GetTailTime() { return (JucePlugin_TailLengthSeconds); }
  353. Float64 GetSampleRate() { return GetOutput(0)->GetStreamFormat().mSampleRate; }
  354. Float64 GetLatency()
  355. {
  356. jassert (GetSampleRate() > 0);
  357. if (GetSampleRate() <= 0)
  358. return 0.0;
  359. return juceFilter->getLatencySamples() / GetSampleRate();
  360. }
  361. //==============================================================================
  362. #if BUILD_AU_CARBON_UI
  363. int GetNumCustomUIComponents()
  364. {
  365. return PluginHostType().isDigitalPerformer() ? 0 : 1;
  366. }
  367. void GetUIComponentDescs (ComponentDescription* inDescArray)
  368. {
  369. inDescArray[0].componentType = kAudioUnitCarbonViewComponentType;
  370. inDescArray[0].componentSubType = JucePlugin_AUSubType;
  371. inDescArray[0].componentManufacturer = JucePlugin_AUManufacturerCode;
  372. inDescArray[0].componentFlags = 0;
  373. inDescArray[0].componentFlagsMask = 0;
  374. }
  375. #endif
  376. //==============================================================================
  377. bool getCurrentPosition (AudioPlayHead::CurrentPositionInfo& info)
  378. {
  379. info.timeSigNumerator = 0;
  380. info.timeSigDenominator = 0;
  381. info.timeInSeconds = 0;
  382. info.editOriginTime = 0;
  383. info.ppqPositionOfLastBarStart = 0;
  384. info.isPlaying = false;
  385. info.isRecording = false;
  386. info.isLooping = false;
  387. info.ppqLoopStart = 0;
  388. info.ppqLoopEnd = 0;
  389. switch (lastSMPTETime.mType)
  390. {
  391. case kSMPTETimeType24: info.frameRate = AudioPlayHead::fps24; break;
  392. case kSMPTETimeType25: info.frameRate = AudioPlayHead::fps25; break;
  393. case kSMPTETimeType30Drop: info.frameRate = AudioPlayHead::fps30drop; break;
  394. case kSMPTETimeType30: info.frameRate = AudioPlayHead::fps30; break;
  395. case kSMPTETimeType2997: info.frameRate = AudioPlayHead::fps2997; break;
  396. case kSMPTETimeType2997Drop: info.frameRate = AudioPlayHead::fps2997drop; break;
  397. //case kSMPTETimeType60:
  398. //case kSMPTETimeType5994:
  399. default: info.frameRate = AudioPlayHead::fpsUnknown; break;
  400. }
  401. if (CallHostBeatAndTempo (&info.ppqPosition, &info.bpm) != noErr)
  402. {
  403. info.ppqPosition = 0;
  404. info.bpm = 0;
  405. }
  406. UInt32 outDeltaSampleOffsetToNextBeat;
  407. double outCurrentMeasureDownBeat;
  408. float num;
  409. UInt32 den;
  410. if (CallHostMusicalTimeLocation (&outDeltaSampleOffsetToNextBeat, &num, &den,
  411. &outCurrentMeasureDownBeat) == noErr)
  412. {
  413. info.timeSigNumerator = (int) num;
  414. info.timeSigDenominator = den;
  415. info.ppqPositionOfLastBarStart = outCurrentMeasureDownBeat;
  416. }
  417. double outCurrentSampleInTimeLine, outCycleStartBeat, outCycleEndBeat;
  418. Boolean playing, playchanged, looping;
  419. if (CallHostTransportState (&playing,
  420. &playchanged,
  421. &outCurrentSampleInTimeLine,
  422. &looping,
  423. &outCycleStartBeat,
  424. &outCycleEndBeat) == noErr)
  425. {
  426. info.isPlaying = playing;
  427. info.timeInSeconds = outCurrentSampleInTimeLine / GetSampleRate();
  428. }
  429. return true;
  430. }
  431. void sendAUEvent (const AudioUnitEventType type, const int index)
  432. {
  433. if (AUEventListenerNotify != 0)
  434. {
  435. auEvent.mEventType = type;
  436. auEvent.mArgument.mParameter.mParameterID = (AudioUnitParameterID) index;
  437. AUEventListenerNotify (0, 0, &auEvent);
  438. }
  439. }
  440. void audioProcessorParameterChanged (AudioProcessor*, int index, float /*newValue*/)
  441. {
  442. sendAUEvent (kAudioUnitEvent_ParameterValueChange, index);
  443. }
  444. void audioProcessorParameterChangeGestureBegin (AudioProcessor*, int index)
  445. {
  446. sendAUEvent (kAudioUnitEvent_BeginParameterChangeGesture, index);
  447. }
  448. void audioProcessorParameterChangeGestureEnd (AudioProcessor*, int index)
  449. {
  450. sendAUEvent (kAudioUnitEvent_EndParameterChangeGesture, index);
  451. }
  452. void audioProcessorChanged (AudioProcessor*)
  453. {
  454. // xxx is there an AU equivalent?
  455. }
  456. bool StreamFormatWritable (AudioUnitScope, AudioUnitElement)
  457. {
  458. return ! IsInitialized();
  459. }
  460. // (these two slightly different versions are because the definition changed between 10.4 and 10.5)
  461. ComponentResult StartNote (MusicDeviceInstrumentID, MusicDeviceGroupID, NoteInstanceID&, UInt32, const MusicDeviceNoteParams&) { return noErr; }
  462. ComponentResult StartNote (MusicDeviceInstrumentID, MusicDeviceGroupID, NoteInstanceID*, UInt32, const MusicDeviceNoteParams&) { return noErr; }
  463. ComponentResult StopNote (MusicDeviceGroupID, NoteInstanceID, UInt32) { return noErr; }
  464. //==============================================================================
  465. ComponentResult Initialize()
  466. {
  467. #if ! JucePlugin_IsSynth
  468. const int numIns = GetInput(0) != 0 ? GetInput(0)->GetStreamFormat().mChannelsPerFrame : 0;
  469. #endif
  470. const int numOuts = GetOutput(0) != 0 ? GetOutput(0)->GetStreamFormat().mChannelsPerFrame : 0;
  471. bool isValidChannelConfig = false;
  472. for (int i = 0; i < numChannelConfigs; ++i)
  473. #if JucePlugin_IsSynth
  474. if (numOuts == channelConfigs[i][1])
  475. #else
  476. if (numIns == channelConfigs[i][0] && numOuts == channelConfigs[i][1])
  477. #endif
  478. isValidChannelConfig = true;
  479. if (! isValidChannelConfig)
  480. return kAudioUnitErr_FormatNotSupported;
  481. JuceAUBaseClass::Initialize();
  482. prepareToPlay();
  483. return noErr;
  484. }
  485. void Cleanup()
  486. {
  487. JuceAUBaseClass::Cleanup();
  488. if (juceFilter != nullptr)
  489. juceFilter->releaseResources();
  490. bufferSpace.setSize (2, 16);
  491. midiEvents.clear();
  492. incomingEvents.clear();
  493. prepared = false;
  494. }
  495. ComponentResult Reset (AudioUnitScope inScope, AudioUnitElement inElement)
  496. {
  497. if (! prepared)
  498. prepareToPlay();
  499. if (juceFilter != nullptr)
  500. juceFilter->reset();
  501. return JuceAUBaseClass::Reset (inScope, inElement);
  502. }
  503. void prepareToPlay()
  504. {
  505. if (juceFilter != nullptr)
  506. {
  507. juceFilter->setPlayConfigDetails (
  508. #if ! JucePlugin_IsSynth
  509. GetInput(0)->GetStreamFormat().mChannelsPerFrame,
  510. #else
  511. 0,
  512. #endif
  513. GetOutput(0)->GetStreamFormat().mChannelsPerFrame,
  514. GetSampleRate(),
  515. GetMaxFramesPerSlice());
  516. bufferSpace.setSize (juceFilter->getNumInputChannels() + juceFilter->getNumOutputChannels(),
  517. GetMaxFramesPerSlice() + 32);
  518. juceFilter->prepareToPlay (GetSampleRate(), GetMaxFramesPerSlice());
  519. midiEvents.ensureSize (2048);
  520. midiEvents.clear();
  521. incomingEvents.ensureSize (2048);
  522. incomingEvents.clear();
  523. channels.calloc (jmax (juceFilter->getNumInputChannels(),
  524. juceFilter->getNumOutputChannels()) + 4);
  525. prepared = true;
  526. }
  527. }
  528. ComponentResult Render (AudioUnitRenderActionFlags &ioActionFlags,
  529. const AudioTimeStamp& inTimeStamp,
  530. UInt32 nFrames)
  531. {
  532. lastSMPTETime = inTimeStamp.mSMPTETime;
  533. #if ! JucePlugin_IsSynth
  534. return JuceAUBaseClass::Render (ioActionFlags, inTimeStamp, nFrames);
  535. #else
  536. // synths can't have any inputs..
  537. AudioBufferList inBuffer;
  538. inBuffer.mNumberBuffers = 0;
  539. return ProcessBufferLists (ioActionFlags, inBuffer, GetOutput(0)->GetBufferList(), nFrames);
  540. #endif
  541. }
  542. OSStatus ProcessBufferLists (AudioUnitRenderActionFlags& ioActionFlags,
  543. const AudioBufferList& inBuffer,
  544. AudioBufferList& outBuffer,
  545. UInt32 numSamples)
  546. {
  547. if (juceFilter != nullptr)
  548. {
  549. jassert (prepared);
  550. int numOutChans = 0;
  551. int nextSpareBufferChan = 0;
  552. bool needToReinterleave = false;
  553. const int numIn = juceFilter->getNumInputChannels();
  554. const int numOut = juceFilter->getNumOutputChannels();
  555. unsigned int i;
  556. for (i = 0; i < outBuffer.mNumberBuffers; ++i)
  557. {
  558. AudioBuffer& buf = outBuffer.mBuffers[i];
  559. if (buf.mNumberChannels == 1)
  560. {
  561. channels [numOutChans++] = (float*) buf.mData;
  562. }
  563. else
  564. {
  565. needToReinterleave = true;
  566. for (unsigned int subChan = 0; subChan < buf.mNumberChannels && numOutChans < numOut; ++subChan)
  567. channels [numOutChans++] = bufferSpace.getSampleData (nextSpareBufferChan++);
  568. }
  569. if (numOutChans >= numOut)
  570. break;
  571. }
  572. int numInChans = 0;
  573. for (i = 0; i < inBuffer.mNumberBuffers; ++i)
  574. {
  575. const AudioBuffer& buf = inBuffer.mBuffers[i];
  576. if (buf.mNumberChannels == 1)
  577. {
  578. if (numInChans < numOutChans)
  579. memcpy (channels [numInChans], (const float*) buf.mData, sizeof (float) * numSamples);
  580. else
  581. channels [numInChans] = (float*) buf.mData;
  582. ++numInChans;
  583. }
  584. else
  585. {
  586. // need to de-interleave..
  587. for (unsigned int subChan = 0; subChan < buf.mNumberChannels && numInChans < numIn; ++subChan)
  588. {
  589. float* dest;
  590. if (numInChans < numOutChans)
  591. {
  592. dest = channels [numInChans++];
  593. }
  594. else
  595. {
  596. dest = bufferSpace.getSampleData (nextSpareBufferChan++);
  597. channels [numInChans++] = dest;
  598. }
  599. const float* src = ((const float*) buf.mData) + subChan;
  600. for (int j = numSamples; --j >= 0;)
  601. {
  602. *dest++ = *src;
  603. src += buf.mNumberChannels;
  604. }
  605. }
  606. }
  607. if (numInChans >= numIn)
  608. break;
  609. }
  610. {
  611. const ScopedLock sl (incomingMidiLock);
  612. midiEvents.clear();
  613. incomingEvents.swapWith (midiEvents);
  614. }
  615. {
  616. AudioSampleBuffer buffer (channels, jmax (numIn, numOut), numSamples);
  617. const ScopedLock sl (juceFilter->getCallbackLock());
  618. if (juceFilter->isSuspended())
  619. {
  620. for (int i = 0; i < numOut; ++i)
  621. zeromem (channels [i], sizeof (float) * numSamples);
  622. }
  623. else
  624. {
  625. juceFilter->processBlock (buffer, midiEvents);
  626. }
  627. }
  628. if (! midiEvents.isEmpty())
  629. {
  630. #if JucePlugin_ProducesMidiOutput
  631. const juce::uint8* midiEventData;
  632. int midiEventSize, midiEventPosition;
  633. MidiBuffer::Iterator i (midiEvents);
  634. while (i.getNextEvent (midiEventData, midiEventSize, midiEventPosition))
  635. {
  636. jassert (isPositiveAndBelow (midiEventPosition, (int) numSamples));
  637. //xxx
  638. }
  639. #else
  640. // if your plugin creates midi messages, you'll need to set
  641. // the JucePlugin_ProducesMidiOutput macro to 1 in your
  642. // JucePluginCharacteristics.h file
  643. //jassert (midiEvents.getNumEvents() <= numMidiEventsComingIn);
  644. #endif
  645. midiEvents.clear();
  646. }
  647. if (needToReinterleave)
  648. {
  649. nextSpareBufferChan = 0;
  650. for (i = 0; i < outBuffer.mNumberBuffers; ++i)
  651. {
  652. AudioBuffer& buf = outBuffer.mBuffers[i];
  653. if (buf.mNumberChannels > 1)
  654. {
  655. for (unsigned int subChan = 0; subChan < buf.mNumberChannels; ++subChan)
  656. {
  657. const float* src = bufferSpace.getSampleData (nextSpareBufferChan++);
  658. float* dest = ((float*) buf.mData) + subChan;
  659. for (int j = numSamples; --j >= 0;)
  660. {
  661. *dest = *src++;
  662. dest += buf.mNumberChannels;
  663. }
  664. }
  665. }
  666. }
  667. }
  668. #if ! JucePlugin_SilenceInProducesSilenceOut
  669. ioActionFlags &= ~kAudioUnitRenderAction_OutputIsSilence;
  670. #endif
  671. }
  672. return noErr;
  673. }
  674. protected:
  675. OSStatus HandleMidiEvent (UInt8 nStatus, UInt8 inChannel, UInt8 inData1, UInt8 inData2,
  676. #if defined (MAC_OS_X_VERSION_10_5)
  677. UInt32 inStartFrame)
  678. #else
  679. long inStartFrame)
  680. #endif
  681. {
  682. #if JucePlugin_WantsMidiInput
  683. const ScopedLock sl (incomingMidiLock);
  684. const juce::uint8 data[] = { (juce::uint8) (nStatus | inChannel),
  685. (juce::uint8) inData1,
  686. (juce::uint8) inData2 };
  687. incomingEvents.addEvent (data, 3, inStartFrame);
  688. #endif
  689. return noErr;
  690. }
  691. OSStatus HandleSysEx (const UInt8* inData, UInt32 inLength)
  692. {
  693. #if JucePlugin_WantsMidiInput
  694. const ScopedLock sl (incomingMidiLock);
  695. incomingEvents.addEvent (inData, inLength, 0);
  696. #endif
  697. return noErr;
  698. }
  699. //==============================================================================
  700. ComponentResult GetPresets (CFArrayRef* outData) const
  701. {
  702. if (outData != nullptr)
  703. {
  704. const int numPrograms = juceFilter->getNumPrograms();
  705. presetsArray.ensureSize (sizeof (AUPreset) * numPrograms, true);
  706. AUPreset* const presets = (AUPreset*) presetsArray.getData();
  707. CFMutableArrayRef presetsArray = CFArrayCreateMutable (0, numPrograms, 0);
  708. for (int i = 0; i < numPrograms; ++i)
  709. {
  710. presets[i].presetNumber = i;
  711. presets[i].presetName = juceFilter->getProgramName(i).toCFString();
  712. CFArrayAppendValue (presetsArray, presets + i);
  713. }
  714. *outData = (CFArrayRef) presetsArray;
  715. }
  716. return noErr;
  717. }
  718. OSStatus NewFactoryPresetSet (const AUPreset& inNewFactoryPreset)
  719. {
  720. const int numPrograms = juceFilter->getNumPrograms();
  721. const SInt32 chosenPresetNumber = (int) inNewFactoryPreset.presetNumber;
  722. if (chosenPresetNumber >= numPrograms)
  723. return kAudioUnitErr_InvalidProperty;
  724. AUPreset chosenPreset;
  725. chosenPreset.presetNumber = chosenPresetNumber;
  726. chosenPreset.presetName = juceFilter->getProgramName (chosenPresetNumber).toCFString();
  727. juceFilter->setCurrentProgram (chosenPresetNumber);
  728. SetAFactoryPresetAsCurrent (chosenPreset);
  729. return noErr;
  730. }
  731. void componentMovedOrResized (Component& component, bool /*wasMoved*/, bool /*wasResized*/)
  732. {
  733. NSView* view = (NSView*) component.getWindowHandle();
  734. NSRect r = [[view superview] frame];
  735. r.origin.y = r.origin.y + r.size.height - component.getHeight();
  736. r.size.width = component.getWidth();
  737. r.size.height = component.getHeight();
  738. [[view superview] setFrame: r];
  739. [view setFrame: NSMakeRect (0, 0, component.getWidth(), component.getHeight())];
  740. [view setNeedsDisplay: YES];
  741. }
  742. private:
  743. //==============================================================================
  744. ScopedPointer<AudioProcessor> juceFilter;
  745. AudioSampleBuffer bufferSpace;
  746. HeapBlock <float*> channels;
  747. MidiBuffer midiEvents, incomingEvents;
  748. bool prepared;
  749. SMPTETime lastSMPTETime;
  750. AUChannelInfo channelInfo [numChannelConfigs];
  751. AudioUnitEvent auEvent;
  752. mutable juce::MemoryBlock presetsArray;
  753. CriticalSection incomingMidiLock;
  754. JUCE_DECLARE_NON_COPYABLE (JuceAU);
  755. };
  756. //==============================================================================
  757. class EditorCompHolder : public Component
  758. {
  759. public:
  760. EditorCompHolder (AudioProcessorEditor* const editor)
  761. {
  762. setSize (editor->getWidth(), editor->getHeight());
  763. addAndMakeVisible (editor);
  764. #if ! JucePlugin_EditorRequiresKeyboardFocus
  765. setWantsKeyboardFocus (false);
  766. #else
  767. setWantsKeyboardFocus (true);
  768. #endif
  769. }
  770. ~EditorCompHolder()
  771. {
  772. deleteAllChildren(); // note that we can't use a ScopedPointer because the editor may
  773. // have been transferred to another parent which takes over ownership.
  774. }
  775. static NSView* createViewFor (AudioProcessor* filter, JuceAU* au, AudioProcessorEditor* const editor)
  776. {
  777. EditorCompHolder* editorCompHolder = new EditorCompHolder (editor);
  778. NSRect r = NSMakeRect (0, 0, editorCompHolder->getWidth(), editorCompHolder->getHeight());
  779. static JuceUIViewClass cls;
  780. NSView* view = [[cls.createInstance() initWithFrame: r] autorelease];
  781. JuceUIViewClass::setFilter (view, filter);
  782. JuceUIViewClass::setAU (view, au);
  783. JuceUIViewClass::setEditor (view, editorCompHolder);
  784. [view setHidden: NO];
  785. [view setPostsFrameChangedNotifications: YES];
  786. [[NSNotificationCenter defaultCenter] addObserver: view
  787. selector: @selector (applicationWillTerminate:)
  788. name: NSApplicationWillTerminateNotification
  789. object: nil];
  790. activeUIs.add (view);
  791. editorCompHolder->addToDesktop (0, (void*) view);
  792. editorCompHolder->setVisible (view);
  793. return view;
  794. }
  795. void childBoundsChanged (Component*)
  796. {
  797. Component* editor = getChildComponent(0);
  798. if (editor != nullptr)
  799. {
  800. const int w = jmax (32, editor->getWidth());
  801. const int h = jmax (32, editor->getHeight());
  802. if (getWidth() != w || getHeight() != h)
  803. setSize (w, h);
  804. NSView* view = (NSView*) getWindowHandle();
  805. NSRect r = [[view superview] frame];
  806. r.size.width = editor->getWidth();
  807. r.size.height = editor->getHeight();
  808. [[view superview] setFrame: r];
  809. [view setFrame: NSMakeRect (0, 0, editor->getWidth(), editor->getHeight())];
  810. [view setNeedsDisplay: YES];
  811. }
  812. }
  813. //==============================================================================
  814. struct JuceUIViewClass : public ObjCClass <NSView>
  815. {
  816. JuceUIViewClass() : ObjCClass <NSView> ("JUCEAUView_")
  817. {
  818. addIvar<AudioProcessor*> ("filter");
  819. addIvar<JuceAU*> ("au");
  820. addIvar<EditorCompHolder*> ("editor");
  821. addMethod (@selector (dealloc), dealloc, "v@:");
  822. addMethod (@selector (applicationWillTerminate:), applicationWillTerminate, "v@:@");
  823. addMethod (@selector (viewDidMoveToWindow), viewDidMoveToWindow, "v@:");
  824. addMethod (@selector (mouseDownCanMoveWindow), mouseDownCanMoveWindow, "c@:");
  825. registerClass();
  826. }
  827. static void deleteEditor (id self)
  828. {
  829. ScopedPointer<EditorCompHolder> editorComp (getEditor (self));
  830. if (editorComp != nullptr)
  831. {
  832. JuceAU* const au = getAU (self);
  833. if (editorComp->getChildComponent(0) != nullptr)
  834. {
  835. if (activePlugins.contains (au)) // plugin may have been deleted before the UI
  836. {
  837. AudioProcessor* const filter = getIvar<AudioProcessor*> (self, "filter");
  838. filter->editorBeingDeleted ((AudioProcessorEditor*) editorComp->getChildComponent(0));
  839. }
  840. }
  841. editorComp = nullptr;
  842. setEditor (self, nullptr);
  843. }
  844. }
  845. static JuceAU* getAU (id self) { return getIvar<JuceAU*> (self, "au"); }
  846. static EditorCompHolder* getEditor (id self) { return getIvar<EditorCompHolder*> (self, "editor"); }
  847. static void setFilter (id self, AudioProcessor* filter) { object_setInstanceVariable (self, "filter", filter); }
  848. static void setAU (id self, JuceAU* au) { object_setInstanceVariable (self, "au", au); }
  849. static void setEditor (id self, EditorCompHolder* e) { object_setInstanceVariable (self, "editor", e); }
  850. private:
  851. static void dealloc (id self, SEL)
  852. {
  853. if (activeUIs.contains (self))
  854. shutdown (self);
  855. sendSuperclassMessage (self, @selector (dealloc));
  856. }
  857. static void applicationWillTerminate (id self, SEL, NSNotification*)
  858. {
  859. shutdown (self);
  860. }
  861. static void shutdown (id self)
  862. {
  863. // there's some kind of component currently modal, but the host
  864. // is trying to delete our plugin..
  865. jassert (Component::getCurrentlyModalComponent() == nullptr);
  866. [[NSNotificationCenter defaultCenter] removeObserver: self];
  867. deleteEditor (self);
  868. jassert (activeUIs.contains (self));
  869. activeUIs.removeValue (self);
  870. if (activePlugins.size() + activeUIs.size() == 0)
  871. shutdownJuce_GUI();
  872. }
  873. static void viewDidMoveToWindow (id self, SEL)
  874. {
  875. NSWindow* w = [(NSView*) self window];
  876. if (w != nil)
  877. {
  878. [w setAcceptsMouseMovedEvents: YES];
  879. EditorCompHolder* const editorComp = getEditor (self);
  880. if (editorComp != nullptr)
  881. [w makeFirstResponder: (NSView*) editorComp->getWindowHandle()];
  882. }
  883. }
  884. static BOOL mouseDownCanMoveWindow (id self, SEL)
  885. {
  886. return NO;
  887. }
  888. };
  889. private:
  890. JUCE_DECLARE_NON_COPYABLE (EditorCompHolder);
  891. };
  892. void JuceAU::deleteActiveEditors()
  893. {
  894. for (int i = activeUIs.size(); --i >= 0;)
  895. {
  896. id ui = (id) activeUIs.getUnchecked(i);
  897. if (EditorCompHolder::JuceUIViewClass::getAU (ui) == this)
  898. EditorCompHolder::JuceUIViewClass::deleteEditor (ui);
  899. }
  900. }
  901. //==============================================================================
  902. @interface JuceUICreationClass : NSObject <AUCocoaUIBase>
  903. {
  904. }
  905. - (unsigned) interfaceVersion;
  906. - (NSString*) description;
  907. - (NSView*) uiViewForAudioUnit: (AudioUnit) inAudioUnit
  908. withSize: (NSSize) inPreferredSize;
  909. @end
  910. @implementation JuceUICreationClass
  911. - (unsigned) interfaceVersion
  912. {
  913. return 0;
  914. }
  915. - (NSString*) description
  916. {
  917. return [NSString stringWithString: nsStringLiteral (JucePlugin_Name)];
  918. }
  919. - (NSView*) uiViewForAudioUnit: (AudioUnit) inAudioUnit
  920. withSize: (NSSize) inPreferredSize
  921. {
  922. void* pointers[2];
  923. UInt32 propertySize = sizeof (pointers);
  924. if (AudioUnitGetProperty (inAudioUnit,
  925. juceFilterObjectPropertyID,
  926. kAudioUnitScope_Global,
  927. 0,
  928. pointers,
  929. &propertySize) != noErr)
  930. return nil;
  931. AudioProcessor* filter = (AudioProcessor*) pointers[0];
  932. JuceAU* au = (JuceAU*) pointers[1];
  933. if (filter == nullptr)
  934. return nil;
  935. AudioProcessorEditor* editorComp = filter->createEditorIfNeeded();
  936. if (editorComp == nullptr)
  937. return nil;
  938. return EditorCompHolder::createViewFor (filter, au, editorComp);
  939. }
  940. @end
  941. #if BUILD_AU_CARBON_UI
  942. //==============================================================================
  943. class JuceAUView : public AUCarbonViewBase
  944. {
  945. public:
  946. JuceAUView (AudioUnitCarbonView auview)
  947. : AUCarbonViewBase (auview),
  948. juceFilter (nullptr)
  949. {
  950. }
  951. ~JuceAUView()
  952. {
  953. deleteUI();
  954. }
  955. ComponentResult CreateUI (Float32 /*inXOffset*/, Float32 /*inYOffset*/)
  956. {
  957. JUCE_AUTORELEASEPOOL
  958. if (juceFilter == nullptr)
  959. {
  960. void* pointers[2];
  961. UInt32 propertySize = sizeof (pointers);
  962. AudioUnitGetProperty (GetEditAudioUnit(),
  963. juceFilterObjectPropertyID,
  964. kAudioUnitScope_Global,
  965. 0,
  966. pointers,
  967. &propertySize);
  968. juceFilter = (AudioProcessor*) pointers[0];
  969. }
  970. if (juceFilter != nullptr)
  971. {
  972. deleteUI();
  973. AudioProcessorEditor* editorComp = juceFilter->createEditorIfNeeded();
  974. editorComp->setOpaque (true);
  975. windowComp = new ComponentInHIView (editorComp, mCarbonPane);
  976. }
  977. else
  978. {
  979. jassertfalse // can't get a pointer to our effect
  980. }
  981. return noErr;
  982. }
  983. AudioUnitCarbonViewEventListener getEventListener() const { return mEventListener; }
  984. void* getEventListenerUserData() const { return mEventListenerUserData; }
  985. private:
  986. //==============================================================================
  987. AudioProcessor* juceFilter;
  988. ScopedPointer<Component> windowComp;
  989. FakeMouseMoveGenerator fakeMouseGenerator;
  990. void deleteUI()
  991. {
  992. if (windowComp != nullptr)
  993. {
  994. PopupMenu::dismissAllActiveMenus();
  995. /* This assertion is triggered when there's some kind of modal component active, and the
  996. host is trying to delete our plugin.
  997. If you must use modal components, always use them in a non-blocking way, by never
  998. calling runModalLoop(), but instead using enterModalState() with a callback that
  999. will be performed on completion. (Note that this assertion could actually trigger
  1000. a false alarm even if you're doing it correctly, but is here to catch people who
  1001. aren't so careful) */
  1002. jassert (Component::getCurrentlyModalComponent() == nullptr);
  1003. EditorCompHolder* editorCompHolder = dynamic_cast <EditorCompHolder*> (windowComp->getChildComponent(0));
  1004. if (editorCompHolder != nullptr)
  1005. {
  1006. AudioProcessorEditor* audioProcessEditor = dynamic_cast <AudioProcessorEditor*> (editorCompHolder->getChildComponent(0));
  1007. if (audioProcessEditor != nullptr)
  1008. juceFilter->editorBeingDeleted (audioProcessEditor);
  1009. }
  1010. windowComp = nullptr;
  1011. }
  1012. }
  1013. //==============================================================================
  1014. // Uses a child NSWindow to sit in front of a HIView and display our component
  1015. class ComponentInHIView : public Component
  1016. {
  1017. public:
  1018. ComponentInHIView (AudioProcessorEditor* const editor_, HIViewRef parentHIView)
  1019. : parentView (parentHIView),
  1020. editor (editor_),
  1021. recursive (false)
  1022. {
  1023. JUCE_AUTORELEASEPOOL
  1024. jassert (editor_ != nullptr);
  1025. addAndMakeVisible (&editor);
  1026. setOpaque (true);
  1027. setVisible (true);
  1028. setBroughtToFrontOnMouseClick (true);
  1029. setSize (editor.getWidth(), editor.getHeight());
  1030. SizeControl (parentHIView, editor.getWidth(), editor.getHeight());
  1031. WindowRef windowRef = HIViewGetWindow (parentHIView);
  1032. hostWindow = [[NSWindow alloc] initWithWindowRef: windowRef];
  1033. [hostWindow retain];
  1034. [hostWindow setCanHide: YES];
  1035. [hostWindow setReleasedWhenClosed: YES];
  1036. updateWindowPos();
  1037. #if ! JucePlugin_EditorRequiresKeyboardFocus
  1038. addToDesktop (ComponentPeer::windowIsTemporary | ComponentPeer::windowIgnoresKeyPresses);
  1039. setWantsKeyboardFocus (false);
  1040. #else
  1041. addToDesktop (ComponentPeer::windowIsTemporary);
  1042. setWantsKeyboardFocus (true);
  1043. #endif
  1044. setVisible (true);
  1045. toFront (false);
  1046. addSubWindow();
  1047. NSWindow* pluginWindow = [((NSView*) getWindowHandle()) window];
  1048. [pluginWindow setNextResponder: hostWindow];
  1049. attachWindowHidingHooks (this, (WindowRef) windowRef, hostWindow);
  1050. }
  1051. ~ComponentInHIView()
  1052. {
  1053. JUCE_AUTORELEASEPOOL
  1054. removeWindowHidingHooks (this);
  1055. NSWindow* pluginWindow = [((NSView*) getWindowHandle()) window];
  1056. [hostWindow removeChildWindow: pluginWindow];
  1057. removeFromDesktop();
  1058. [hostWindow release];
  1059. hostWindow = nil;
  1060. }
  1061. void updateWindowPos()
  1062. {
  1063. HIPoint f;
  1064. f.x = f.y = 0;
  1065. HIPointConvert (&f, kHICoordSpaceView, parentView, kHICoordSpaceScreenPixel, 0);
  1066. setTopLeftPosition ((int) f.x, (int) f.y);
  1067. }
  1068. void addSubWindow()
  1069. {
  1070. NSWindow* pluginWindow = [((NSView*) getWindowHandle()) window];
  1071. [pluginWindow setExcludedFromWindowsMenu: YES];
  1072. [pluginWindow setCanHide: YES];
  1073. [hostWindow addChildWindow: pluginWindow
  1074. ordered: NSWindowAbove];
  1075. [hostWindow orderFront: nil];
  1076. [pluginWindow orderFront: nil];
  1077. }
  1078. void resized()
  1079. {
  1080. Component* const child = getChildComponent (0);
  1081. if (child != nullptr)
  1082. child->setBounds (getLocalBounds());
  1083. }
  1084. void paint (Graphics&) {}
  1085. void childBoundsChanged (Component*)
  1086. {
  1087. if (! recursive)
  1088. {
  1089. recursive = true;
  1090. const int w = jmax (32, editor.getWidth());
  1091. const int h = jmax (32, editor.getHeight());
  1092. SizeControl (parentView, w, h);
  1093. if (getWidth() != w || getHeight() != h)
  1094. setSize (w, h);
  1095. editor.repaint();
  1096. updateWindowPos();
  1097. addSubWindow(); // (need this for AULab)
  1098. recursive = false;
  1099. }
  1100. }
  1101. bool keyPressed (const KeyPress& kp)
  1102. {
  1103. if (! kp.getModifiers().isCommandDown())
  1104. {
  1105. // If we have an unused keypress, move the key-focus to a host window
  1106. // and re-inject the event..
  1107. static NSTimeInterval lastEventTime = 0; // check we're not recursively sending the same event
  1108. if (lastEventTime != [[NSApp currentEvent] timestamp])
  1109. {
  1110. lastEventTime = [[NSApp currentEvent] timestamp];
  1111. [[hostWindow parentWindow] makeKeyWindow];
  1112. [NSApp postEvent: [NSApp currentEvent] atStart: YES];
  1113. }
  1114. }
  1115. return false;
  1116. }
  1117. private:
  1118. HIViewRef parentView;
  1119. NSWindow* hostWindow;
  1120. EditorCompHolder editor;
  1121. bool recursive;
  1122. };
  1123. };
  1124. #endif
  1125. //==============================================================================
  1126. #define JUCE_COMPONENT_ENTRYX(Class, Name, Suffix) \
  1127. extern "C" __attribute__((visibility("default"))) ComponentResult Name ## Suffix (ComponentParameters* params, Class* obj); \
  1128. extern "C" __attribute__((visibility("default"))) ComponentResult Name ## Suffix (ComponentParameters* params, Class* obj) \
  1129. { \
  1130. return ComponentEntryPoint<Class>::Dispatch(params, obj); \
  1131. }
  1132. #define JUCE_COMPONENT_ENTRY(Class, Name, Suffix) JUCE_COMPONENT_ENTRYX(Class, Name, Suffix)
  1133. JUCE_COMPONENT_ENTRY (JuceAU, JucePlugin_AUExportPrefix, Entry)
  1134. #if BUILD_AU_CARBON_UI
  1135. JUCE_COMPONENT_ENTRY (JuceAUView, JucePlugin_AUExportPrefix, ViewEntry)
  1136. #endif
  1137. #endif