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.

101 lines
3.1KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2015 - ROLI 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. void MessageManager::runDispatchLoop()
  18. {
  19. jassert (isThisTheMessageThread()); // must only be called by the message thread
  20. while (! quitMessagePosted)
  21. {
  22. JUCE_AUTORELEASEPOOL
  23. {
  24. [[NSRunLoop currentRunLoop] runMode: NSDefaultRunLoopMode
  25. beforeDate: [NSDate dateWithTimeIntervalSinceNow: 0.001]];
  26. }
  27. }
  28. }
  29. void MessageManager::stopDispatchLoop()
  30. {
  31. if (! SystemStats::isRunningInAppExtensionSandbox())
  32. [[[UIApplication sharedApplication] delegate] applicationWillTerminate: [UIApplication sharedApplication]];
  33. exit (0); // iOS apps get no mercy..
  34. }
  35. #if JUCE_MODAL_LOOPS_PERMITTED
  36. bool MessageManager::runDispatchLoopUntil (int millisecondsToRunFor)
  37. {
  38. JUCE_AUTORELEASEPOOL
  39. {
  40. jassert (isThisTheMessageThread()); // must only be called by the message thread
  41. uint32 startTime = Time::getMillisecondCounter();
  42. NSDate* endDate = [NSDate dateWithTimeIntervalSinceNow: millisecondsToRunFor * 0.001];
  43. while (! quitMessagePosted)
  44. {
  45. JUCE_AUTORELEASEPOOL
  46. {
  47. [[NSRunLoop currentRunLoop] runMode: NSDefaultRunLoopMode
  48. beforeDate: endDate];
  49. if (millisecondsToRunFor >= 0
  50. && Time::getMillisecondCounter() >= startTime + (uint32) millisecondsToRunFor)
  51. break;
  52. }
  53. }
  54. return ! quitMessagePosted;
  55. }
  56. }
  57. #endif
  58. //==============================================================================
  59. static ScopedPointer<MessageQueue> messageQueue;
  60. void MessageManager::doPlatformSpecificInitialisation()
  61. {
  62. if (messageQueue == nullptr)
  63. messageQueue = new MessageQueue();
  64. }
  65. void MessageManager::doPlatformSpecificShutdown()
  66. {
  67. messageQueue = nullptr;
  68. }
  69. bool MessageManager::postMessageToSystemQueue (MessageManager::MessageBase* const message)
  70. {
  71. if (messageQueue != nullptr)
  72. messageQueue->post (message);
  73. return true;
  74. }
  75. void MessageManager::broadcastMessage (const String&)
  76. {
  77. // N/A on current iOS
  78. }