soundvision/UnityProject/Assets/ThridParty/Keijiro/Internal/K4aExtensions.cs

30 lines
917 B
C#
Raw Permalink Normal View History

2019-12-12 12:08:41 +00:00
using System.Reflection;
namespace Akvfx
{
static class K4aExtensions
{
// Set false to Allocator.SafeCopyNativeBuffers. You can earn a few
// milliseconds by skipping safe-copy. Note that it turns minor bugs
// undebuggable crashes.
public static void DisableSafeCopyNativeBuffers()
{
var allocator = System.Type.GetType(
"Microsoft.Azure.Kinect.Sensor.Allocator,Microsoft.Azure.Kinect.Sensor"
);
var singleton = allocator.GetProperty(
"Singleton",
BindingFlags.Public | BindingFlags.Static
);
var safeCopyNativeBuffers = allocator.GetProperty(
"SafeCopyNativeBuffers",
BindingFlags.Public | BindingFlags.Instance
);
safeCopyNativeBuffers.SetValue(singleton.GetValue(null), false);
}
}
}