Audio plugin host https://kx.studio/carla
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.

113 lines
4.3KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2013 - Raw Material Software Ltd.
  5. Permission is granted to use this software under the terms of either:
  6. a) the GPL v2 (or any later version)
  7. b) the Affero GPL v3
  8. Details of these licenses can be found at: www.gnu.org/licenses
  9. JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
  10. WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  11. A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  12. ------------------------------------------------------------------------------
  13. To release a closed-source product which uses JUCE, commercial licenses are
  14. available: visit www.juce.com for more information.
  15. ==============================================================================
  16. */
  17. #ifndef JUCE_INITIALISATION_H_INCLUDED
  18. #define JUCE_INITIALISATION_H_INCLUDED
  19. //==============================================================================
  20. /** Initialises Juce's GUI classes.
  21. If you're embedding Juce into an application that uses its own event-loop rather
  22. than using the START_JUCE_APPLICATION macro, call this function before making any
  23. Juce calls, to make sure things are initialised correctly.
  24. Note that if you're creating a Juce DLL for Windows, you may also need to call the
  25. Process::setCurrentModuleInstanceHandle() method.
  26. @see shutdownJuce_GUI()
  27. */
  28. JUCE_API void JUCE_CALLTYPE initialiseJuce_GUI();
  29. /** Clears up any static data being used by Juce's GUI classes.
  30. If you're embedding Juce into an application that uses its own event-loop rather
  31. than using the START_JUCE_APPLICATION macro, call this function in your shutdown
  32. code to clean up any juce objects that might be lying around.
  33. @see initialiseJuce_GUI()
  34. */
  35. JUCE_API void JUCE_CALLTYPE shutdownJuce_GUI();
  36. //==============================================================================
  37. /** A utility object that helps you initialise and shutdown Juce correctly
  38. using an RAII pattern.
  39. When the first instance of this class is created, it calls initialiseJuce_GUI(),
  40. and when the last instance is deleted, it calls shutdownJuce_GUI(), so that you
  41. can easily be sure that as long as at least one instance of the class exists, the
  42. library will be initialised.
  43. This class is particularly handy to use at the beginning of a console app's
  44. main() function, because it'll take care of shutting down whenever you return
  45. from the main() call.
  46. Be careful with your threading though - to be safe, you should always make sure
  47. that these objects are created and deleted on the message thread.
  48. */
  49. class JUCE_API ScopedJuceInitialiser_GUI
  50. {
  51. public:
  52. /** The constructor simply calls initialiseJuce_GUI(). */
  53. ScopedJuceInitialiser_GUI();
  54. /** The destructor simply calls shutdownJuce_GUI(). */
  55. ~ScopedJuceInitialiser_GUI();
  56. };
  57. //==============================================================================
  58. /**
  59. To start a JUCE app, use this macro: START_JUCE_APPLICATION (AppSubClass) where
  60. AppSubClass is the name of a class derived from JUCEApplication or JUCEApplicationBase.
  61. See the JUCEApplication and JUCEApplicationBase class documentation for more details.
  62. */
  63. #ifdef DOXYGEN
  64. #define START_JUCE_APPLICATION(AppClass)
  65. #elif JUCE_ANDROID
  66. #define START_JUCE_APPLICATION(AppClass) \
  67. juce::JUCEApplicationBase* juce_CreateApplication() { return new AppClass(); }
  68. #else
  69. #if JUCE_WINDOWS && ! defined (_CONSOLE)
  70. #define JUCE_MAIN_FUNCTION int __stdcall WinMain (struct HINSTANCE__*, struct HINSTANCE__*, char*, int)
  71. #define JUCE_MAIN_FUNCTION_ARGS
  72. #else
  73. #define JUCE_MAIN_FUNCTION int main (int argc, char* argv[])
  74. #define JUCE_MAIN_FUNCTION_ARGS argc, (const char**) argv
  75. #endif
  76. #define START_JUCE_APPLICATION(AppClass) \
  77. static juce::JUCEApplicationBase* juce_CreateApplication() { return new AppClass(); } \
  78. extern "C" JUCE_MAIN_FUNCTION \
  79. { \
  80. juce::JUCEApplicationBase::createInstance = &juce_CreateApplication; \
  81. return juce::JUCEApplicationBase::main (JUCE_MAIN_FUNCTION_ARGS); \
  82. }
  83. #endif
  84. #endif // JUCE_INITIALISATION_H_INCLUDED