cleanup of MIDI code dependencies

* make the critical section local to the respective platform instead of polluting everything with system specific symbols.
* moved system specific class declarations into the source file instead of having them in the global header.

This commit temporarily disables the Windows system device because it cannot be done without polluting the global header and still needs a bit of refactoring.
This commit is contained in:
Christoph Oelckers 2017-03-10 16:12:52 +01:00
commit 8d6fe24945
23 changed files with 456 additions and 378 deletions

58
src/win32/critsec.cpp Normal file
View file

@ -0,0 +1,58 @@
// Wraps a Windows critical section object.
#ifndef _WINNT_
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#define USE_WINDOWS_DWORD
#endif
class FInternalCriticalSection
{
public:
FInternalCriticalSection()
{
InitializeCriticalSection(&CritSec);
}
~FInternalCriticalSection()
{
DeleteCriticalSection(&CritSec);
}
void Enter()
{
EnterCriticalSection(&CritSec);
}
void Leave()
{
LeaveCriticalSection(&CritSec);
}
#if 0
// SDL has no equivalent functionality, so better not use it on Windows.
bool TryEnter()
{
return TryEnterCriticalSection(&CritSec) != 0;
}
#endif
private:
CRITICAL_SECTION CritSec;
};
FInternalCriticalSection *CreateCriticalSection()
{
return new FInternalCriticalSection();
}
void DeleteCriticalSection(FInternalCriticalSection *c)
{
delete c;
}
void EnterCriticalSection(FInternalCriticalSection *c)
{
c->Enter();
}
void LeaveCriticalSection(FInternalCriticalSection *c)
{
c->Leave();
}