Added: Voicemeeter audio processing support. When Voicemeeter is installed, it can be selected in the Configurator.

This commit is contained in:
jthedering committed 2017-03-12 12:53:24 +00:00
1 parent 46d921945f
commit 989812ba36
55 files changed
+3044 -278

No files matched your search

+115
View File
@@ -0,0 +1,115 @@
#ifndef SCOPEGUARD_H
#define SCOPEGUARD_H
// Taken from "Declarative Control Flow" (CppCon 2015)
// adjusted to work with Visual C++ 2013
#include <exception>
#include <utility>
#if defined(_MSC_VER) && (_MSC_VER < 1900)
#define noexcept
#endif
#include "UncaughtExceptions.h"
#if defined(_MSC_VER) && (_MSC_VER < 1900)
#undef noexcept
#endif
#define CONCATENATE_IMPL(s1, s2) s1 ## s2
#define CONCATENATE(s1, s2) CONCATENATE_IMPL(s1, s2)
#ifdef __COUNTER__
#define ANONYMOUS_VARIABLE(str) CONCATENATE(str, __COUNTER__)
#else
#define ANONYMOUS_VARIABLE(str) CONCATENATE(str, __LINE__)
#endif
namespace detail {
enum class ScopeGuardOnExit
{
};
enum class ScopeGuardOnFail
{
};
enum class ScopeGuardOnSuccess
{
};
template<typename Fun> class ScopeGuard
{
public:
ScopeGuard(Fun&& fn)
: fn(std::move(fn))
{
}
~ScopeGuard()
{
fn();
}
private:
Fun fn;
};
class UncaughtExceptionCounter
{
int exceptionCount_;
public:
UncaughtExceptionCounter()
: exceptionCount_(folly::uncaught_exceptions())
{
}
bool newUncaughtException()
{
return folly::uncaught_exceptions() > exceptionCount_;
}
};
template<typename FunctionType, bool executeOnException> class ScopeGuardForNewException
{
FunctionType function_;
UncaughtExceptionCounter ec_;
public:
explicit ScopeGuardForNewException(const FunctionType& fn)
: function_(fn)
{
}
explicit ScopeGuardForNewException(FunctionType&& fn)
: function_(std::move(fn))
{
}
~ScopeGuardForNewException()
{
if (executeOnException == ec_.newUncaughtException())
{
function_();
}
}
};
template<typename Fun> ScopeGuard<Fun> operator+(ScopeGuardOnExit, Fun&& fn)
{
return ScopeGuard<Fun>(std::forward<Fun>(fn));
}
template<typename Fun> ScopeGuardForNewException<typename std::decay_t<Fun>, true> operator+(detail::ScopeGuardOnFail, Fun&& fn)
{
return ScopeGuardForNewException<typename std::decay_t<Fun>, true>(std::forward<Fun>(fn));
}
template<typename Fun> ScopeGuardForNewException<typename std::decay_t<Fun>, false> operator+(detail::ScopeGuardOnSuccess, Fun&& fn)
{
return ScopeGuardForNewException<typename std::decay_t<Fun>, false>(std::forward<Fun>(fn));
}
}
#define SCOPE_FAIL auto ANONYMOUS_VARIABLE(SCOPE_FAIL_STATE) = ::detail::ScopeGuardOnFail() +[&]()
#define SCOPE_SUCCESS auto ANONYMOUS_VARIABLE(SCOPE_FAIL_STATE) = ::detail::ScopeGuardOnSuccess() +[&]()
#define SCOPE_EXIT auto ANONYMOUS_VARIABLE(SCOPE_EXIT_STATE) = ::detail::ScopeGuardOnExit() +[&]()
#endif
+66
View File
@@ -0,0 +1,66 @@
/*
* Copyright 2017 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#pragma once
#include <exception>
#if defined(__GNUG__) || defined(__CLANG__)
#define FOLLY_EXCEPTION_COUNT_USE_CXA_GET_GLOBALS
namespace __cxxabiv1 {
// forward declaration (originally defined in unwind-cxx.h from from libstdc++)
struct __cxa_eh_globals;
// declared in cxxabi.h from libstdc++-v3
extern "C" __cxa_eh_globals* __cxa_get_globals() noexcept;
}
#elif defined(_MSC_VER) && (_MSC_VER >= 1400) && \
(_MSC_VER < 1900) // MSVC++ 8.0 or greater
#define FOLLY_EXCEPTION_COUNT_USE_GETPTD
// forward declaration (originally defined in mtdll.h from MSVCRT)
struct _tiddata;
extern "C" _tiddata* _getptd(); // declared in mtdll.h from MSVCRT
#elif defined(_MSC_VER) && (_MSC_VER >= 1900) // MSVC++ 2015
#define FOLLY_EXCEPTION_COUNT_USE_STD
#else
// Raise an error when trying to use this on unsupported platforms.
#error "Unsupported platform, don't include this header."
#endif
namespace folly {
/**
* Returns the number of uncaught exceptions.
*
* This function is based on Evgeny Panasyuk's implementation from here:
* http://fburl.com/15190026
*/
inline int uncaught_exceptions() noexcept {
#if defined(FOLLY_EXCEPTION_COUNT_USE_CXA_GET_GLOBALS)
// __cxa_get_globals returns a __cxa_eh_globals* (defined in unwind-cxx.h).
// The offset below returns __cxa_eh_globals::uncaughtExceptions.
return *(reinterpret_cast<unsigned int*>(static_cast<char*>(
static_cast<void*>(__cxxabiv1::__cxa_get_globals())) + sizeof(void*)));
#elif defined(FOLLY_EXCEPTION_COUNT_USE_GETPTD)
// _getptd() returns a _tiddata* (defined in mtdll.h).
// The offset below returns _tiddata::_ProcessingThrow.
return *(reinterpret_cast<int*>(static_cast<char*>(
static_cast<void*>(_getptd())) + sizeof(void*) * 28 + 0x4 * 8));
#elif defined(FOLLY_EXCEPTION_COUNT_USE_STD)
return std::uncaught_exceptions();
#endif
}
} // namespaces