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.

CarlaMainLoop.hpp 2.0KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /*
  2. * Carla Main-Loop utils
  3. * Copyright (C) 2017 Filipe Coelho <falktx@falktx.com>
  4. *
  5. * This program is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU General Public License as
  7. * published by the Free Software Foundation; either version 2 of
  8. * the License, or any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * For a full copy of the GNU General Public License see the doc/GPL.txt file.
  16. */
  17. #ifndef CARLA_MAIN_LOOP_HPP_INCLUDED
  18. #define CARLA_MAIN_LOOP_HPP_INCLUDED
  19. #include "CarlaBackend.h"
  20. #include "CarlaUtils.hpp"
  21. #ifdef CARLA_OS_MAC
  22. # import <Cocoa/Cocoa.h>
  23. #endif
  24. // ---------------------------------------------------------------------------------------------------------------------
  25. CARLA_BACKEND_START_NAMESPACE
  26. static inline
  27. bool runMainLoopOnce()
  28. {
  29. #if defined(CARLA_OS_MAC)
  30. NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
  31. NSEvent* event;
  32. for (;;)
  33. {
  34. event = [NSApp
  35. nextEventMatchingMask:NSAnyEventMask
  36. untilDate:[NSDate distantPast]
  37. inMode:NSDefaultRunLoopMode
  38. dequeue:YES];
  39. if (event == nil)
  40. break;
  41. [NSApp sendEvent: event];
  42. }
  43. [pool release];
  44. #elif defined(CARLA_OS_WIN)
  45. MSG msg;
  46. if (! ::PeekMessage(&msg, nullptr, 0, 0, PM_NOREMOVE))
  47. return true;
  48. if (::GetMessage(&msg, nullptr, 0, 0) >= 0)
  49. {
  50. if (msg.message == WM_QUIT)
  51. return false;
  52. //TranslateMessage(&msg);
  53. DispatchMessage(&msg);
  54. }
  55. #endif
  56. return true;
  57. }
  58. CARLA_BACKEND_END_NAMESPACE
  59. // ---------------------------------------------------------------------------------------------------------------------
  60. #endif // CARLA_MAIN_LOOP_HPP_INCLUDED