From 9b487aae0e3e7e5384c2b16758acbcce23261af2 Mon Sep 17 00:00:00 2001 From: Garry Newman Date: Thu, 7 May 2020 11:54:27 +0100 Subject: [PATCH] Added IntPtr version of DecompressVoice --- Facepunch.Steamworks/SteamUser.cs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/Facepunch.Steamworks/SteamUser.cs b/Facepunch.Steamworks/SteamUser.cs index d197687..e481d84 100644 --- a/Facepunch.Steamworks/SteamUser.cs +++ b/Facepunch.Steamworks/SteamUser.cs @@ -261,6 +261,9 @@ namespace Steamworks return (int)szWritten; } + /// + /// Lazy version + /// public static unsafe int DecompressVoice( byte[] from, System.IO.Stream output ) { var to = Helpers.TakeBuffer( 1024 * 64 ); @@ -284,6 +287,22 @@ namespace Steamworks return (int)szWritten; } + /// + /// Advanced and potentially fastest version - incase you know what you're doing + /// + public static unsafe int DecompressVoice( IntPtr from, int length, IntPtr to, int bufferSize ) + { + if ( length <= 0 ) throw new ArgumentException( $"length should be > 0 " ); + if ( bufferSize <= 0 ) throw new ArgumentException( $"bufferSize should be > 0 " ); + + uint szWritten = 0; + + if ( Internal.DecompressVoice( from, (uint) length, to, (uint)bufferSize, ref szWritten, SampleRate ) != VoiceResult.OK ) + return 0; + + return (int)szWritten; + } + /// /// Retrieve a authentication ticket to be sent to the entity who wishes to authenticate you. ///