Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

terminate with useful message in case PortAudio is missing on startup #10

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 27 additions & 4 deletions SDRSharp/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -396,11 +396,20 @@ public MainForm()
_streamControl = new StreamControl(_streamHookManager);

InitializeComponent();
InitializeGUI();
InitialiseSharpPlugins();
}

private void InitializeGUI()
public bool Initialize()
{
if (InitializeGUI())
{
InitialiseSharpPlugins();
return true;
}

return false;
}

private bool InitializeGUI()
{
_initializing = true;

Expand All @@ -427,7 +436,20 @@ private void InitializeGUI()

var defaultIndex = 0;
var savedIndex = -1;
var devices = AudioDevice.GetDevices(DeviceDirection.Input);
List<AudioDevice> devices;
try
{
devices = AudioDevice.GetDevices(DeviceDirection.Input);
}
catch(TypeInitializationException tEx)
{
MessageBox.Show(
$"{ this.Text } needs the PortAudio v19 library to work:\n{ tEx.Message }\n\nInstall and configure PortAudio first.", $"Could not start { this.Text }",
MessageBoxButtons.OK, MessageBoxIcon.Information);

return false;
}

var savedDeviceName = Utils.GetStringSetting("inputDevice", string.Empty);
for (var i = 0; i < devices.Count; i++)
{
Expand Down Expand Up @@ -681,6 +703,7 @@ private void InitializeGUI()
#endregion

_initializing = false;
return true;
}

private void ExtIO_LOFreqChanged(int frequency)
Expand Down
6 changes: 5 additions & 1 deletion SDRSharp/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,11 @@ static void Main()

Control.CheckForIllegalCrossThreadCalls = false;
Application.EnableVisualStyles();
Application.Run(new MainForm());
var mainForm = new MainForm();
if (mainForm.Initialize())
{
Application.Run(mainForm);
}

if (Environment.OSVersion.Platform == PlatformID.Win32Windows || Environment.OSVersion.Platform == PlatformID.Win32NT)
{
Expand Down