// SPDX-License-Identifier: GPL-3.0-only #pragma once #include #include #include // Experimental lifetime repair for the pinned Meta XR Audio Wwise build. // A queued metadata object must not be reclaimed while the current immutable // AkAudioObjects snapshot still references it. Preserve the SDK's queue mutex, // virtual destructor, list linkage, audio processing, and dirty-flag writes. static _Thread_local const unsigned char *mx_audio_objects; static unsigned mx_audio_held,mx_audio_reclaimed; static int mx_audio_referenced(const void *pointer) { if(!mx_audio_objects)return 0; uint32_t count;memcpy(&count,mx_audio_objects,4); const unsigned char *const *objects;memcpy(&objects,mx_audio_objects+16,8); // Refuse to reclaim on an unrecognised snapshot rather than dereferencing // unbounded arrays. These bounds exceed the game's ordinary voice counts. if(count>4096 || (count && !objects))return 1; for(unsigned i=0;i4096 || (metadata_count && !metadata))return 1; for(unsigned j=0;j