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.

69 lines
1.8KB

  1. /*
  2. * DISTRHO Plugin Framework (DPF)
  3. * Copyright (C) 2012-2016 Filipe Coelho <falktx@falktx.com>
  4. *
  5. * Permission to use, copy, modify, and/or distribute this software for any purpose with
  6. * or without fee is hereby granted, provided that the above copyright notice and this
  7. * permission notice appear in all copies.
  8. *
  9. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD
  10. * TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN
  11. * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
  12. * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
  13. * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
  14. * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  15. */
  16. #ifndef DISTRHO_SLEEP_HPP_INCLUDED
  17. #define DISTRHO_SLEEP_HPP_INCLUDED
  18. #include "../DistrhoUtils.hpp"
  19. #ifdef DISTRHO_OS_WINDOWS
  20. # include <winsock2.h>
  21. # include <windows.h>
  22. #else
  23. # include <unistd.h>
  24. #endif
  25. // -----------------------------------------------------------------------
  26. // d_*sleep
  27. /*
  28. * Sleep for 'secs' seconds.
  29. */
  30. static inline
  31. void d_sleep(const uint secs) noexcept
  32. {
  33. DISTRHO_SAFE_ASSERT_RETURN(secs > 0,);
  34. try {
  35. #ifdef DISTRHO_OS_WINDOWS
  36. ::Sleep(secs * 1000);
  37. #else
  38. ::sleep(secs);
  39. #endif
  40. } DISTRHO_SAFE_EXCEPTION("d_sleep");
  41. }
  42. /*
  43. * Sleep for 'msecs' milliseconds.
  44. */
  45. static inline
  46. void d_msleep(const uint msecs) noexcept
  47. {
  48. DISTRHO_SAFE_ASSERT_RETURN(msecs > 0,);
  49. try {
  50. #ifdef DISTRHO_OS_WINDOWS
  51. ::Sleep(msecs);
  52. #else
  53. ::usleep(msecs * 1000);
  54. #endif
  55. } DISTRHO_SAFE_EXCEPTION("d_msleep");
  56. }
  57. // -----------------------------------------------------------------------
  58. #endif // DISTRHO_SLEEP_HPP_INCLUDED