// Port of pflib/external/openal/oalContext.h (Apple OpenAL, Playground SDK 4.0): OALContext, an AL context: one // 3DMixer node in its device's AUGraph with one bus per source (BusInfo), the listener state and the source maps. // Layout from the DWARF of parity-out/sdk/dbgobj/oalContext.o (game offsets identical, constructor // game @0x00121d58): // // OALContext (size 184): +0x00 mSelfToken, +0x04 mProcessingActive, +0x08 mOwningDevice, +0x0c mMixerNode, // +0x10 mMixerUnit, +0x14 mSourceMap, +0x18 mDeadSourceMap, +0x1c mDistanceModel, +0x20 mSpeedOfSound, // +0x24 mDopplerFactor, +0x28 mDopplerVelocity, +0x2c mListenerPosition[3], +0x38 mListenerVelocity[3], // +0x44 mListenerGain, +0x48 mListenerOrientationForward[3], +0x54 mListenerOrientationUp[3], // +0x60 mAttributeListSize, +0x64 mAttributeList, +0x68 mDistanceScalingRequired, +0x69 mCalculateDistance, // +0x6c mStoredInverseAttenuation, +0x74 mRenderQuality, +0x78 mSpatialSetting, +0x7c mBusCount, // +0x80 mMixerOutputRate, +0x88 mDefaultReferenceDistance, +0x8c mDefaultMaxDistance, // +0x90 mUserSpecifiedBusCounts, +0x94 mBusInfo, +0x98 mSettableMixerAttenuationCurves, +0x9c mASAReverbState, // +0xa0 mASAReverbRoomType, +0xa4 mASAReverbGlobalLevel, +0xa8 mASAReverbQuality, +0xac mASAReverbEQGain, // +0xb0 mASAReverbEQBandwidth, +0xb4 mASAReverbEQFrequency. // BusInfo (size 12): +0x00 mIsAvailable, +0x04 mNumberChannels, +0x08 mReverbState. // // Header code (inline members below) is emitted out of line in the SDK objects (addresses at each member) and // inlined in the game. OALContextMap (also declared in Apple's oalContext.h) is oalImp code and ported at the // bottom of this header: its out-of-line code is in the SDK's oalImp.o (sdk @); the game inlines its calls. // Members declared without a definition have no game code and are not ported (sdk only, listed in // oalContext.cpp). #ifndef OALCONTEXT_H_INCLUDED #define OALCONTEXT_H_INCLUDED #include "oal_sysdecls.h" #include "oalDevice.h" #include "oalSource.h" #include #include #include struct BusInfo { bool mIsAvailable; UInt32 mNumberChannels; UInt32 mReverbState; }; class OALContext { public: OALContext(const uintptr_t inSelfToken, OALDevice* inOALDevice, const ALCint* inAttributeList, UInt32& inBusCount, Float64& inMixerRate); ~OALContext(); // sdk @0x34a9c (oalSource.o) bool DoSetDistance() { return mCalculateDistance; } UInt32 GetDesiredRenderChannels(UInt32 inDeviceChannels); // sdk @0x34aae (oalSource.o) AudioUnit GetMixerUnit() { return mMixerUnit; } // sdk @0x34abc (oalSource.o) AUNode GetMixerNode() { return mMixerNode; } // sdk @0x34aca (oalSource.o) AUGraph GetGraph() { return mOwningDevice->GetGraph(); } // sdk @0x5a964 (oalImp.o) UInt32 GetRenderQuality() { return mRenderQuality; } // sdk @0x5a972 (oalImp.o) Float32 GetFramesPerSlice() { return mOwningDevice->GetFramesPerSlice(); } // sdk @0x34ae0 (oalSource.o) Float64 GetMixerRate() const { return mMixerOutputRate; } // sdk @0x34afc (oalSource.o) Float32 GetDefaultReferenceDistance() { return mDefaultReferenceDistance; } // sdk @0x34b1e (oalSource.o) Float32 GetDefaultMaxDistance() { return mDefaultMaxDistance; } // sdk @0x34b40 (oalSource.o) bool IsDistanceScalingRequired() { return mDistanceScalingRequired; } UInt32 GetAvailableMonoBus(); UInt32 GetAvailableStereoBus(); // sdk @0x5a9da (oalImp.o) UInt32 GetBusCount() { return mBusCount; } // sdk @0x5a9e8 (oalImp.o) uintptr_t GetDeviceToken() { return mOwningDevice->GetDeviceToken(); } // sdk @0x34b52 (oalSource.o) UInt32 GetDistanceModel() { return mDistanceModel; } // sdk @0x34b60 (oalSource.o) Float32 GetSpeedOfSound() { return mSpeedOfSound; } // sdk @0x34b7e (oalSource.o) Float32 GetDopplerFactor() { return mDopplerFactor; } // sdk @0x5aa48 (oalImp.o) Float32 GetDopplerVelocity() { return mDopplerVelocity; } // sdk @0x5aa66 (oalImp.o) Float32 GetListenerGain() { return mListenerGain; } // sdk @0x34b9c (oalSource.o) void GetListenerPosition(Float32* posX, Float32* posY, Float32* posZ) { *posX = mListenerPosition[0]; *posY = mListenerPosition[1]; *posZ = mListenerPosition[2]; } // sdk @0x34bc6 (oalSource.o) void GetListenerVelocity(Float32* posX, Float32* posY, Float32* posZ) { *posX = mListenerVelocity[0]; *posY = mListenerVelocity[1]; *posZ = mListenerVelocity[2]; } // sdk @0x34bf0 (oalSource.o) void GetListenerOrientation(Float32* forwardX, Float32* forwardY, Float32* forwardZ, Float32* upX, Float32* upY, Float32* upZ) { *forwardX = mListenerOrientationForward[0]; *forwardY = mListenerOrientationForward[1]; *forwardZ = mListenerOrientationForward[2]; *upX = mListenerOrientationUp[0]; *upY = mListenerOrientationUp[1]; *upZ = mListenerOrientationUp[2]; } // sdk @0x5ab22 (oalImp.o) UInt32 GetAttributeListSize() { return mAttributeListSize; } void CopyAttributeList(ALCint* outAttrList); void SetReverbQuality(UInt32 inQuality); void SetReverbEQGain(Float32 inGain); void SetReverbEQBandwidth(Float32 inBandwidth); void SetReverbEQFrequency(Float32 inFrequency); UInt32 GetReverbQuality(); Float32 GetReverbEQGain(); Float32 GetReverbEQBandwidth(); Float32 GetReverbEQFrequency(); void SetBusAsAvailable(UInt32 inBusIndex); void SetDistanceAttenuation(UInt32 inBusIndex, Float64 inRefDist, Float64 inMaxDist, Float64 inRolloff); void SetRenderQuality(UInt32 inRenderQuality); void SetDistanceModel(UInt32 inDistanceModel); void SetDopplerFactor(Float32 inDopplerFactor); void SetDopplerVelocity(Float32 inDopplerVelocity); void SetSpeedOfSound(Float32 inSpeedOfSound); void SetListenerPosition(Float32 posX, Float32 posY, Float32 posZ); void SetListenerVelocity(Float32 posX, Float32 posY, Float32 posZ); void SetListenerGain(Float32 inGain); void SetListenerOrientation(Float32 forwardX, Float32 forwardY, Float32 forwardZ, Float32 upX, Float32 upY, Float32 upZ); void SetReverbPreset(FSRef* inRef); void SetReverbState(UInt32 inReverbState); // sdk @0x34c3a (oalSource.o) UInt32 GetReverbState() { return mASAReverbState; } void SetReverbRoomType(UInt32 inRoomType); void SetReverbLevel(Float32 inReverbLevel); UInt32 GetReverbRoomType(); Float32 GetReverbLevel(); void ProcessContext(); void SuspendContext(); void AddSource(ALuint inSourceToken); void RemoveSource(ALuint inSourceToken); OALSource* GetSource(ALuint inSourceToken); UInt32 GetSourceCount(); void CleanUpDeadSourceList(); void ConnectMixerToDevice(); void InitRenderQualityOnBusses(); void ConfigureMixerFormat(); private: void InitializeMixer(UInt32 inStereoBusCount); uintptr_t mSelfToken; bool mProcessingActive; OALDevice* mOwningDevice; AUNode mMixerNode; AudioUnit mMixerUnit; OALSourceMap* mSourceMap; OALSourceMap* mDeadSourceMap; UInt32 mDistanceModel; Float32 mSpeedOfSound; Float32 mDopplerFactor; Float32 mDopplerVelocity; Float32 mListenerPosition[3]; Float32 mListenerVelocity[3]; Float32 mListenerGain; Float32 mListenerOrientationForward[3]; Float32 mListenerOrientationUp[3]; UInt32 mAttributeListSize; ALCint* mAttributeList; bool mDistanceScalingRequired; bool mCalculateDistance; Float64 mStoredInverseAttenuation; UInt32 mRenderQuality; UInt32 mSpatialSetting; UInt32 mBusCount; Float64 mMixerOutputRate; Float32 mDefaultReferenceDistance; Float32 mDefaultMaxDistance; bool mUserSpecifiedBusCounts; BusInfo* mBusInfo; bool mSettableMixerAttenuationCurves; UInt32 mASAReverbState; UInt32 mASAReverbRoomType; Float32 mASAReverbGlobalLevel; UInt32 mASAReverbQuality; Float32 mASAReverbEQGain; Float32 mASAReverbEQBandwidth; Float32 mASAReverbEQFrequency; }; // The context map of oalImp.cpp (gOALContextMap). Every member with out-of-line code has it in the SDK's // oalImp.o (sdk @ below); the game inlines all of them. Empty() has no out-of-line code in either build // (nothing calls it) and the map is never deleted (no ~OALContextMap symbol in either build). class OALContextMap : std::multimap > { public: // sdk @0x5d094 (oalImp.o) OALContextMap() {} // sdk @0x5d9d8 (oalImp.o) void Add(const uintptr_t inContextToken, OALContext** inContext) { iterator it = upper_bound(inContextToken); insert(it, value_type(inContextToken, *inContext)); } // sdk @0x5bc76 (oalImp.o) OALContext* Get(uintptr_t inContextToken) { iterator it = find(inContextToken); if (it != end()) { return ((*it).second); } return (NULL); } // sdk @0x5c666 (oalImp.o) bool Remove(const uintptr_t inContextToken) { iterator it = find(inContextToken); if (it != end()) { erase(it); return true; // success } return false; } // sdk @0x5b9ee (oalImp.o) OALContext* GetContextByIndex(UInt32 inIndex, uintptr_t& outContextToken) { iterator it = begin(); std::advance(it, inIndex); if (it != end()) { outContextToken = (*it).first; return (*it).second; } return (NULL); } // sdk @0x5bcd4 (oalImp.o) uintptr_t GetDeviceTokenForContext(uintptr_t inContextToken) { OALContext* context = Get(inContextToken); if (context != NULL) { return (context->GetDeviceToken()); } else { return (0); } } // sdk @0x5ae98 (oalImp.o) UInt32 Size() const { return (UInt32)size(); } // no out-of-line code in either build (nothing calls it) bool Empty() const { return empty(); } }; #endif