mirror of
https://github.com/Facepunch/Facepunch.Steamworks.git
synced 2024-12-25 06:05:46 +03:00
Added test GetVoice_Compressed_Only, GetVoice_UnCompressed_Only
This commit is contained in:
parent
d4eb325606
commit
aa1aac50af
@ -87,28 +87,92 @@ public void GetVoice()
|
||||
{
|
||||
using ( var client = new Facepunch.Steamworks.Client( 252490 ) )
|
||||
{
|
||||
int dataRead = 0;
|
||||
int unCompressed = 0;
|
||||
int compressed = 0;
|
||||
|
||||
client.Voice.OnCompressedData = ( data ) =>
|
||||
{
|
||||
dataRead += data.Length;
|
||||
compressed += data.Length;
|
||||
};
|
||||
|
||||
client.Voice.OnUncompressedData = ( data ) =>
|
||||
{
|
||||
dataRead += data.Length;
|
||||
unCompressed += data.Length;
|
||||
};
|
||||
|
||||
client.Voice.WantsRecording = true;
|
||||
|
||||
for ( int i = 0; i < 32; i++ )
|
||||
var sw = Stopwatch.StartNew();
|
||||
|
||||
while ( sw.Elapsed.TotalSeconds < 3 )
|
||||
{
|
||||
client.Update();
|
||||
System.Threading.Thread.Sleep( 10 );
|
||||
}
|
||||
|
||||
Assert.AreNotEqual( unCompressed, 0 );
|
||||
Assert.AreNotEqual( compressed, 0 );
|
||||
|
||||
// Should really be > 0 if the mic was getting audio
|
||||
Console.Write( dataRead );
|
||||
Console.WriteLine( "unCompressed: {0}", unCompressed );
|
||||
Console.WriteLine( "compressed: {0}", compressed );
|
||||
}
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void GetVoice_Compressed_Only()
|
||||
{
|
||||
using ( var client = new Facepunch.Steamworks.Client( 252490 ) )
|
||||
{
|
||||
int compressed = 0;
|
||||
|
||||
client.Voice.OnCompressedData = ( data ) =>
|
||||
{
|
||||
compressed += data.Length;
|
||||
};
|
||||
|
||||
client.Voice.WantsRecording = true;
|
||||
|
||||
var sw = Stopwatch.StartNew();
|
||||
|
||||
while ( sw.Elapsed.TotalSeconds < 3 )
|
||||
{
|
||||
client.Update();
|
||||
System.Threading.Thread.Sleep( 10 );
|
||||
}
|
||||
|
||||
Assert.AreNotEqual( compressed, 0 );
|
||||
Console.WriteLine( "compressed: {0}", compressed );
|
||||
}
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void GetVoice_UnCompressed_Only()
|
||||
{
|
||||
using ( var client = new Facepunch.Steamworks.Client( 252490 ) )
|
||||
{
|
||||
int unCompressed = 0;
|
||||
|
||||
client.Voice.OnUncompressedData = ( data ) =>
|
||||
{
|
||||
unCompressed += data.Length;
|
||||
};
|
||||
|
||||
client.Voice.WantsRecording = true;
|
||||
|
||||
var sw = Stopwatch.StartNew();
|
||||
|
||||
while ( sw.Elapsed.TotalSeconds < 3 )
|
||||
{
|
||||
client.Update();
|
||||
System.Threading.Thread.Sleep( 10 );
|
||||
}
|
||||
|
||||
Assert.AreNotEqual( unCompressed, 0 );
|
||||
|
||||
// Should really be > 0 if the mic was getting audio
|
||||
Console.WriteLine( "unCompressed: {0}", unCompressed );
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -87,8 +87,8 @@ internal unsafe void Update()
|
||||
bufferRegularLastWrite = 0;
|
||||
bufferCompressedLastWrite = 0;
|
||||
|
||||
Valve.Steamworks.EVoiceResult result = (Valve.Steamworks.EVoiceResult) client.native.user.GetVoice( OnUncompressedData != null, (IntPtr) pbufferCompressed, (uint) bufferCompressed.Length, ref bufferCompressedLastWrite,
|
||||
OnCompressedData != null, (IntPtr) pbufferRegular, (uint) bufferRegular.Length, ref bufferRegularLastWrite,
|
||||
Valve.Steamworks.EVoiceResult result = (Valve.Steamworks.EVoiceResult) client.native.user.GetVoice( OnCompressedData != null, (IntPtr) pbufferCompressed, (uint) bufferCompressed.Length, ref bufferCompressedLastWrite,
|
||||
OnUncompressedData != null, (IntPtr) pbufferRegular, (uint) bufferRegular.Length, ref bufferRegularLastWrite,
|
||||
DesiredSampleRate == 0 ? OptimalSampleRate : DesiredSampleRate );
|
||||
|
||||
IsRecording = true;
|
||||
|
Loading…
Reference in New Issue
Block a user