Port managed client audio and Windows application
This commit is contained in:
@@ -5,7 +5,7 @@ namespace VoiceCat.App;
|
||||
internal static class Program
|
||||
{
|
||||
[STAThread]
|
||||
private static void Main()
|
||||
private static int Main(string[] args)
|
||||
{
|
||||
// Surface exceptions that WinForms' default message-loop handling would otherwise
|
||||
// swallow silently (or crash with no visible cause).
|
||||
@@ -16,12 +16,37 @@ internal static class Program
|
||||
|
||||
ApplicationConfiguration.Initialize();
|
||||
|
||||
if (args.Contains("--smoke-test"))
|
||||
{
|
||||
try
|
||||
{
|
||||
using var client = new VoiceCat.Interop.VoiceCatClient("Smoke", "test");
|
||||
using var form = new MainForm(client, 0, "Smoke", "Managed core");
|
||||
form.CreateControl();
|
||||
if (form.Controls.Count == 0 || string.IsNullOrEmpty(form.Text)) return 1;
|
||||
client.PumpEvents();
|
||||
if (args.Contains("--audio"))
|
||||
{
|
||||
var backend = new Audio.WasapiAudioBackend();
|
||||
using var playback = backend.OpenPlayback();
|
||||
int samples = 0;
|
||||
using var capture = backend.OpenCapture(null, false, (pcm, _) => Interlocked.Add(ref samples, pcm.Length));
|
||||
short[] silence = new short[1920];
|
||||
for (int i = 0; i < 150; i++) { playback.Write(silence); Thread.Sleep(20); }
|
||||
if (samples == 0) return 2;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
catch { return 1; }
|
||||
}
|
||||
|
||||
using var connectDialog = new ConnectDialog();
|
||||
var result = connectDialog.ShowDialog();
|
||||
if (result != DialogResult.OK || connectDialog.ConnectedClient is null)
|
||||
return;
|
||||
return 0;
|
||||
|
||||
Application.Run(new MainForm(connectDialog.ConnectedClient, connectDialog.SelfUserId,
|
||||
connectDialog.Nickname, connectDialog.ServerName));
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user