Browse Source

Move sleep funcs into separate file, so we don't include windows.h

gh-pages
falkTX 9 years ago
parent
commit
5a325b8a56
10 changed files with 71 additions and 58 deletions
  1. +0
    -6
      dgl/Window.hpp
  2. +0
    -2
      dgl/src/App.cpp
  3. +1
    -0
      dgl/src/AppPrivateData.hpp
  4. +3
    -5
      dgl/src/ImageButton.cpp
  5. +0
    -1
      dgl/src/ImageKnob.cpp
  6. +0
    -3
      dgl/src/Widget.cpp
  7. +0
    -3
      dgl/src/Window.cpp
  8. +0
    -38
      distrho/DistrhoUtils.hpp
  9. +5
    -0
      distrho/extra/d_mutex.hpp
  10. +62
    -0
      distrho/extra/d_sleep.hpp

+ 0
- 6
dgl/Window.hpp View File

@@ -19,12 +19,6 @@

#include "Geometry.hpp"

#ifdef PROPER_CPP11_SUPPORT
# include <cstdint>
#else
# include <stdint.h>
#endif

START_NAMESPACE_DGL

// -----------------------------------------------------------------------


+ 0
- 2
dgl/src/App.cpp View File

@@ -17,8 +17,6 @@
#include "AppPrivateData.hpp"
#include "../Window.hpp"

#include <list>

START_NAMESPACE_DGL

// -----------------------------------------------------------------------


+ 1
- 0
dgl/src/AppPrivateData.hpp View File

@@ -18,6 +18,7 @@
#define DGL_APP_PRIVATE_DATA_HPP_INCLUDED

#include "../App.hpp"
#include "../../distrho/extra/d_sleep.hpp"

#include <list>



+ 3
- 5
dgl/src/ImageButton.cpp View File

@@ -16,8 +16,6 @@

#include "../ImageButton.hpp"

#include <cassert>

START_NAMESPACE_DGL

// -----------------------------------------------------------------------
@@ -42,7 +40,7 @@ ImageButton::ImageButton(Window& parent, const Image& imageNormal, const Image&
fCurButton(-1),
fCallback(nullptr)
{
assert(fImageNormal.getSize() == fImageHover.getSize() && fImageHover.getSize() == fImageDown.getSize());
DISTRHO_SAFE_ASSERT(fImageNormal.getSize() == fImageHover.getSize() && fImageHover.getSize() == fImageDown.getSize());

setSize(fCurImage->getSize());
}
@@ -67,7 +65,7 @@ ImageButton::ImageButton(Widget* widget, const Image& imageNormal, const Image&
fCurButton(-1),
fCallback(nullptr)
{
assert(fImageNormal.getSize() == fImageHover.getSize() && fImageHover.getSize() == fImageDown.getSize());
DISTRHO_SAFE_ASSERT(fImageNormal.getSize() == fImageHover.getSize() && fImageHover.getSize() == fImageDown.getSize());

setSize(fCurImage->getSize());
}
@@ -81,7 +79,7 @@ ImageButton::ImageButton(const ImageButton& imageButton)
fCurButton(-1),
fCallback(imageButton.fCallback)
{
assert(fImageNormal.getSize() == fImageHover.getSize() && fImageHover.getSize() == fImageDown.getSize());
DISTRHO_SAFE_ASSERT(fImageNormal.getSize() == fImageHover.getSize() && fImageHover.getSize() == fImageDown.getSize());

setSize(fCurImage->getSize());
}


+ 0
- 1
dgl/src/ImageKnob.cpp View File

@@ -17,7 +17,6 @@
#include "../ImageKnob.hpp"

#include <cmath>
#include <cstdio>

START_NAMESPACE_DGL



+ 0
- 3
dgl/src/Widget.cpp View File

@@ -14,12 +14,9 @@
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/

#include "../App.hpp"
#include "../Widget.hpp"
#include "../Window.hpp"

#include <cassert>

START_NAMESPACE_DGL

// -----------------------------------------------------------------------


+ 0
- 3
dgl/src/Window.cpp View File

@@ -21,9 +21,6 @@
#include "../Widget.hpp"
#include "../Window.hpp"

#include <cstdio>
#include <list>

#include "pugl/pugl.h"

#if defined(DISTRHO_OS_WINDOWS)


+ 0
- 38
distrho/DistrhoUtils.hpp View File

@@ -30,13 +30,6 @@
# include <stdint.h>
#endif

#ifdef DISTRHO_OS_WINDOWS
# include <winsock2.h>
# include <windows.h>
#else
# include <unistd.h>
#endif

#if defined(DISTRHO_OS_MAC) && ! defined(CARLA_OS_MAC)
namespace std {
inline float
@@ -135,37 +128,6 @@ void d_safe_exception(const char* const exception, const char* const file, const
d_stderr2("exception caught: \"%s\" in file %s, line %i", exception, file, line);
}

// -----------------------------------------------------------------------
// d_*sleep

static inline
void d_sleep(const uint secs) noexcept
{
DISTRHO_SAFE_ASSERT_RETURN(secs > 0,);

try {
#ifdef DISTRHO_OS_WINDOWS
::Sleep(secs * 1000);
#else
::sleep(secs);
#endif
} DISTRHO_SAFE_EXCEPTION("d_sleep");
}

static inline
void d_msleep(const uint msecs) noexcept
{
DISTRHO_SAFE_ASSERT_RETURN(msecs > 0,);

try {
#ifdef DISTRHO_OS_WINDOWS
::Sleep(msecs);
#else
::usleep(msecs * 1000);
#endif
} DISTRHO_SAFE_EXCEPTION("d_msleep");
}

// -----------------------------------------------------------------------

#endif // DISTRHO_UTILS_HPP_INCLUDED

+ 5
- 0
distrho/extra/d_mutex.hpp View File

@@ -19,6 +19,11 @@

#include "../DistrhoUtils.hpp"

#ifdef DISTRHO_OS_WINDOWS
# include <winsock2.h>
# include <windows.h>
#endif

#include <pthread.h>

// -----------------------------------------------------------------------


+ 62
- 0
distrho/extra/d_sleep.hpp View File

@@ -0,0 +1,62 @@
/*
* DISTRHO Plugin Framework (DPF)
* Copyright (C) 2012-2014 Filipe Coelho <falktx@falktx.com>
*
* Permission to use, copy, modify, and/or distribute this software for any purpose with
* or without fee is hereby granted, provided that the above copyright notice and this
* permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD
* TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN
* NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/

#ifndef DISTRHO_SLEEP_HPP_INCLUDED
#define DISTRHO_SLEEP_HPP_INCLUDED

#include "../DistrhoUtils.hpp"

#ifdef DISTRHO_OS_WINDOWS
# include <winsock2.h>
# include <windows.h>
#else
# include <unistd.h>
#endif

// -----------------------------------------------------------------------
// d_*sleep

static inline
void d_sleep(const uint secs) noexcept
{
DISTRHO_SAFE_ASSERT_RETURN(secs > 0,);

try {
#ifdef DISTRHO_OS_WINDOWS
::Sleep(secs * 1000);
#else
::sleep(secs);
#endif
} DISTRHO_SAFE_EXCEPTION("d_sleep");
}

static inline
void d_msleep(const uint msecs) noexcept
{
DISTRHO_SAFE_ASSERT_RETURN(msecs > 0,);

try {
#ifdef DISTRHO_OS_WINDOWS
::Sleep(msecs);
#else
::usleep(msecs * 1000);
#endif
} DISTRHO_SAFE_EXCEPTION("d_msleep");
}

// -----------------------------------------------------------------------

#endif // DISTRHO_SLEEP_HPP_INCLUDED

Loading…
Cancel
Save