mirror of
https://github.com/Facepunch/Facepunch.Steamworks.git
synced 2024-12-28 15:45:29 +03:00
Added ReadVoiceDataBytes
This commit is contained in:
parent
3b2c7a5a16
commit
ebfecfe25c
@ -175,6 +175,33 @@ public static unsafe int ReadVoiceData( System.IO.Stream stream )
|
|||||||
return (int) szWritten;
|
return (int) szWritten;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Reads the voice data and returns the bytes. You should obviously ideally be using
|
||||||
|
/// ReadVoiceData because it won't be creating a new byte array every call. But this
|
||||||
|
/// makes it easier to get it working, so let the babies have their bottle.
|
||||||
|
/// </summary>
|
||||||
|
public static unsafe byte[] ReadVoiceDataBytes()
|
||||||
|
{
|
||||||
|
if ( !HasVoiceData )
|
||||||
|
return null;
|
||||||
|
|
||||||
|
uint szWritten = 0;
|
||||||
|
uint deprecated = 0;
|
||||||
|
|
||||||
|
fixed ( byte* b = readBuffer )
|
||||||
|
{
|
||||||
|
if ( Internal.GetVoice( true, (IntPtr)b, (uint)readBuffer.Length, ref szWritten, false, IntPtr.Zero, 0, ref deprecated, 0 ) != VoiceResult.OK )
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( szWritten == 0 )
|
||||||
|
return null;
|
||||||
|
|
||||||
|
var arry = new byte[szWritten];
|
||||||
|
Array.Copy( readBuffer, 0, arry, 0, szWritten );
|
||||||
|
return arry;
|
||||||
|
}
|
||||||
|
|
||||||
static uint sampleRate = 48000;
|
static uint sampleRate = 48000;
|
||||||
|
|
||||||
public static uint SampleRate
|
public static uint SampleRate
|
||||||
|
Loading…
Reference in New Issue
Block a user