Voice, decompress

This commit is contained in:
Garry Newman 2016-07-18 12:48:22 +01:00
parent 865f85bc53
commit e70f1b738b
2 changed files with 32 additions and 1 deletions

View File

@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
@ -110,5 +111,35 @@ internal unsafe void Update()
IsRecording = false;
}
}
public unsafe bool Decompress( byte[] input, int inputoffset, int inputsize, MemoryStream output, uint samepleRate = 0 )
{
if ( samepleRate == 0 )
samepleRate = OptimalSampleRate;
//
// Guessing the uncompressed size cuz we're dicks
//
{
var targetBufferSize = inputsize * 10;
if ( output.Capacity < targetBufferSize )
output.Capacity = targetBufferSize;
output.SetLength( targetBufferSize );
}
fixed ( byte* pout = output.GetBuffer() )
fixed ( byte* p = input )
{
uint bytesOut = 0;
var result = (Valve.Steamworks.EVoiceResult) client.native.user.DecompressVoice( (IntPtr)( p + inputoffset ), (uint) inputsize, (IntPtr) pout, (uint) output.Length, ref bytesOut, (uint)samepleRate );
if ( bytesOut > 0 )
output.SetLength( bytesOut );
return result == Valve.Steamworks.EVoiceResult.k_EVoiceResultOK;
}
}
}
}

View File

@ -117,7 +117,6 @@
<Compile Include="Client.Overlay.cs" />
<Compile Include="Client.ServerList.cs" />
<Compile Include="Client.ServerList.Request.cs" />
<Compile Include="Client.Voice.cs" />
<Compile Include="Client.Auth.cs" />
<Compile Include="Client.cs" />
<Compile Include="Client\App.cs" />
@ -125,6 +124,7 @@
<Compile Include="Client\Image.cs" />
<Compile Include="Client\Inventory.cs" />
<Compile Include="Client\Stats.cs" />
<Compile Include="Client\Voice.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="steam_api_interop.cs" />
</ItemGroup>