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.

107 lines
3.5KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2016 - ROLI Ltd.
  5. Permission is granted to use this software under the terms of the ISC license
  6. http://www.isc.org/downloads/software-support-policy/isc-license/
  7. Permission to use, copy, modify, and/or distribute this software for any
  8. purpose with or without fee is hereby granted, provided that the above
  9. copyright notice and this permission notice appear in all copies.
  10. THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH REGARD
  11. TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
  12. FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT,
  13. OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
  14. USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  15. TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
  16. OF THIS SOFTWARE.
  17. -----------------------------------------------------------------------------
  18. To release a closed-source product which uses other parts of JUCE not
  19. licensed under the ISC terms, commercial licenses are available: visit
  20. www.juce.com for more information.
  21. ==============================================================================
  22. */
  23. void MessageManager::runDispatchLoop()
  24. {
  25. jassert (isThisTheMessageThread()); // must only be called by the message thread
  26. while (! quitMessagePosted)
  27. {
  28. JUCE_AUTORELEASEPOOL
  29. {
  30. [[NSRunLoop currentRunLoop] runMode: NSDefaultRunLoopMode
  31. beforeDate: [NSDate dateWithTimeIntervalSinceNow: 0.001]];
  32. }
  33. }
  34. }
  35. void MessageManager::stopDispatchLoop()
  36. {
  37. if (! SystemStats::isRunningInAppExtensionSandbox())
  38. [[[UIApplication sharedApplication] delegate] applicationWillTerminate: [UIApplication sharedApplication]];
  39. exit (0); // iOS apps get no mercy..
  40. }
  41. #if JUCE_MODAL_LOOPS_PERMITTED
  42. bool MessageManager::runDispatchLoopUntil (int millisecondsToRunFor)
  43. {
  44. JUCE_AUTORELEASEPOOL
  45. {
  46. jassert (isThisTheMessageThread()); // must only be called by the message thread
  47. uint32 startTime = Time::getMillisecondCounter();
  48. NSDate* endDate = [NSDate dateWithTimeIntervalSinceNow: millisecondsToRunFor * 0.001];
  49. while (! quitMessagePosted)
  50. {
  51. JUCE_AUTORELEASEPOOL
  52. {
  53. [[NSRunLoop currentRunLoop] runMode: NSDefaultRunLoopMode
  54. beforeDate: endDate];
  55. if (millisecondsToRunFor >= 0
  56. && Time::getMillisecondCounter() >= startTime + (uint32) millisecondsToRunFor)
  57. break;
  58. }
  59. }
  60. return ! quitMessagePosted;
  61. }
  62. }
  63. #endif
  64. //==============================================================================
  65. static ScopedPointer<MessageQueue> messageQueue;
  66. void MessageManager::doPlatformSpecificInitialisation()
  67. {
  68. if (messageQueue == nullptr)
  69. messageQueue = new MessageQueue();
  70. }
  71. void MessageManager::doPlatformSpecificShutdown()
  72. {
  73. messageQueue = nullptr;
  74. }
  75. bool MessageManager::postMessageToSystemQueue (MessageManager::MessageBase* const message)
  76. {
  77. if (messageQueue != nullptr)
  78. messageQueue->post (message);
  79. return true;
  80. }
  81. void MessageManager::broadcastMessage (const String&)
  82. {
  83. // N/A on current iOS
  84. }