I'm having issues with a custom device using the C# SDK with mono 5.14 on Ubuntu 18.04 x64. I've taken the full client example code and snipped out the bits I don't need, added a custom device (virtualDevice), and added the following Task which is meant to acquire data from the custom device every 20 ms and process it. The client consistently runs fine for around 213 seconds, then hangs. After several seconds the client then displays a "Dropping client 1 because of ping timeout 19 0 0" error, however the client stays unresponsive. If I comment out the AcquireData method, the Task and counter runs indefinitely. I've compiled the app with the -debug flag, and run it with --debug but it's not showing any errors when it hangs. No idea why this task would be causing the hang. Custom device thread safety?
Code:
var virtualDevice = new CustomDevice(
"VirtualDevice",
// Playback
SamplingRate.Hz16000,
1,
// Capture
SamplingRate.Hz16000,
1);
Connection.OpenPlayback(virtualDevice);
Connection.OpenCapture(virtualDevice);
<snip>
Task.Run(() =>
{var count = 0;
var samples = (int)(16000 * 0.02);
var buffer = new short[samples];
while (true)
{
if (virtualDevice.AcquireData(buffer, samples))
{
// Do something with the voice data
}
else
{
// Do something else
}
count++;
if (count % 50 == 0)
{
// Display a counter every second so that I can tell exactly when it hangs
Console.WriteLine(count / 50);
}
Thread.Sleep(20);
}
});