1:1 source port of the engine and game code; Windows build and system layer; docs. No game files or SDK headers.
This commit is contained in:
parent
c3b032a45a
commit
0ecb47e9cb
3871 changed files with 91080 additions and 1640063 deletions
56
port/external/openal/oal_sysdecls.h
vendored
Normal file
56
port/external/openal/oal_sysdecls.h
vendored
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
// System API declarations for the port of Apple's OpenAL implementation (pflib/external/openal, Playground SDK 4.0).
|
||||
// Not an SDK file: it gathers the system headers the OpenAL sources include and states the host differences that
|
||||
// concern every file of this directory.
|
||||
//
|
||||
// The SDK was built against the Mac OS X 10.4u SDK for i386. The AudioUnit / AUGraph / AudioConverter / CoreAudio
|
||||
// HAL / Component Manager calls are kept exactly as the game calls them. The current macOS SDK still declares all
|
||||
// of them with their original signatures (several only as deprecated): AUGraphNewNode and AUGraphGetNodeInfo
|
||||
// (AUGraph.h, deprecated in 10.5, with struct ComponentDescription from CarbonCore Components.h),
|
||||
// AudioDeviceGetPropertyInfo / AudioDeviceGetProperty / AudioHardwareGetProperty (AudioHardwareDeprecated.h) and
|
||||
// CompareAndSwap (DriverSynchronization.h), so nothing has to be declared here by hand.
|
||||
//
|
||||
// Host differences (i386 / 10.4u SDK -> LP64 / current SDK):
|
||||
// - UInt32 / SInt32 were unsigned long / long on i386 (the mangled names of the game use 'm' = unsigned long);
|
||||
// the port keeps Apple's UInt32 / SInt32, which are 32-bit on the host as well.
|
||||
// - OSStatus was SInt32 = long on i386. Exceptions thrown as OSStatus therefore have the type long in the game
|
||||
// (typeinfo __ZTIl, non-lazy pointer @0x002264dc) and are distinct from the int of `throw -1` (__ZTIi,
|
||||
// @0x002264d8): catch (OSStatus) does not catch -1. On the host OSStatus is int, which would merge both, so
|
||||
// OSStatus exceptions are thrown and caught as OALStatusException (long) and -1 stays an int.
|
||||
// - AudioUnit is a ComponentInstance (ComponentInstanceRecord*) in both SDKs on the desktop.
|
||||
// - Pointers are 64-bit: TAtomicStack's CompareAndSwap on a pointer is done with a pointer-sized compare-and-swap
|
||||
// on the host (oalAtomicStack.h).
|
||||
|
||||
#ifndef OAL_SYSDECLS_H_INCLUDED
|
||||
#define OAL_SYSDECLS_H_INCLUDED
|
||||
|
||||
#include <AudioToolbox/AudioToolbox.h>
|
||||
#include <AudioUnit/AudioUnit.h>
|
||||
#include <CoreAudio/CoreAudio.h>
|
||||
#include <CoreServices/CoreServices.h>
|
||||
#include <OpenAL/al.h>
|
||||
#include <OpenAL/alc.h>
|
||||
|
||||
#include <pthread.h>
|
||||
|
||||
// The type of an OSStatus thrown by the OpenAL implementation (long on i386, see above).
|
||||
typedef long OALStatusException;
|
||||
|
||||
// Float64 -> UInt32 conversion exactly as gcc 4.0 compiles `(UInt32)x` for i386 with SSE2 (game e.g.
|
||||
// @0x0012267f..@0x001226c4): the value is clamped with minsd(x, 4294967295.0) and maxsd(.., 0.0), 2^31 is
|
||||
// subtracted when 2^31 <= x, cvttsd2si truncates (0x80000000 when out of range) and the sign bit is put back.
|
||||
// Defined for every input, including NaN (-> 0x80000000) and out-of-range values, where a plain C++ conversion
|
||||
// is undefined on the host.
|
||||
inline UInt32 OALConvertFloat64ToUInt32(Float64 x)
|
||||
{
|
||||
bool high = (2147483648.0 <= x);
|
||||
Float64 v = (x < 4294967295.0) ? x : 4294967295.0;
|
||||
v = (v > 0.0) ? v : 0.0;
|
||||
if (high)
|
||||
{
|
||||
v -= 2147483648.0;
|
||||
}
|
||||
UInt32 i = (v < 2147483648.0) ? (UInt32)(SInt32)v : 0x80000000u;
|
||||
return high ? (i ^ 0x80000000u) : i;
|
||||
}
|
||||
|
||||
#endif
|
||||
Loading…
Add table
Add a link
Reference in a new issue