Skip to content

Commit

Permalink
Merge pull request #244 from MorpheusXAUT/audio-init-error-messages
Browse files Browse the repository at this point in the history
Added hint about Win10 microphone privacy options for audio input errors
  • Loading branch information
ciribob authored May 25, 2018
2 parents 7b62681 + 77ee8f9 commit 41d38e4
Show file tree
Hide file tree
Showing 6 changed files with 527 additions and 446 deletions.
39 changes: 35 additions & 4 deletions DCS-SR-Client/Audio/Managers/AudioManager.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Diagnostics;
using System.Net;
using System.Threading;
using System.Windows;
Expand All @@ -18,6 +19,7 @@
using NAudio.Wave;
using NAudio.Wave.SampleProviders;
using NLog;
using WPFCustomMessageBox;
using Application = FragLabs.Audio.Codecs.Opus.Application;

namespace Ciribob.DCS.SimpleRadio.Standalone.Client.Audio.Managers
Expand Down Expand Up @@ -252,10 +254,39 @@ public void StartEncoding(int mic, MMDevice speakers, string guid, InputDeviceMa
{
Logger.Error(ex, "Error starting audio Input - Quitting! " + ex.Message);

MessageBox.Show(
$"Problem Initialising Audio Input! Try a different Input device and please post your client log on the forums",
"Audio Input Error", MessageBoxButton.OK,
MessageBoxImage.Error);
if (Environment.OSVersion.Version.Major == 10)
{
var messageBoxResult = CustomMessageBox.ShowYesNoCancel(
"Problem initialising Audio Input!\n\nIf you are using Windows 10, this could be caused by your privacy settings (make sure to allow apps to access your microphone).\nAlternatively, try a different Input device and please post your client log to the support Discord server.",
"Audio Input Error",
"OPEN PRIVACY SETTINGS",
"JOIN DISCORD SERVER",
"CLOSE",
MessageBoxImage.Error);

if (messageBoxResult == MessageBoxResult.Yes)
{
Process.Start("ms-settings:privacy-microphone");
}
else if (messageBoxResult == MessageBoxResult.No)
{
Process.Start("https://discord.gg/baw7g3t");
}
}
else
{
var messageBoxResult = CustomMessageBox.ShowYesNo(
"Problem initialising Audio Input!\n\nTry a different Input device and please post your client log to the support Discord server.",
"Audio Input Error",
"JOIN DISCORD SERVER",
"CLOSE",
MessageBoxImage.Error);

if (messageBoxResult == MessageBoxResult.Yes)
{
Process.Start("https://discord.gg/baw7g3t");
}
}

Environment.Exit(1);
}
Expand Down
52 changes: 45 additions & 7 deletions DCS-SR-Client/Audio/Managers/AudioPreview.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Windows;
using Ciribob.DCS.SimpleRadio.Standalone.Client.Audio.Managers;
using Ciribob.DCS.SimpleRadio.Standalone.Client.Audio.Utility;
Expand All @@ -12,6 +13,7 @@
using NAudio.Wave;
using NAudio.Wave.SampleProviders;
using NLog;
using WPFCustomMessageBox;

namespace Ciribob.DCS.SimpleRadio.Standalone.Client.Audio
{
Expand Down Expand Up @@ -103,11 +105,18 @@ public void StartPreview(int mic, MMDevice speakers)
{
Logger.Error(ex, "Error starting audio Output - Quitting! " + ex.Message);

MessageBox.Show(
$"Problem Initialising Audio Output! Try a different Output device and please post your client log on the forums",
"Audio Output Error", MessageBoxButton.OK,
var messageBoxResult = CustomMessageBox.ShowYesNo(
"Problem initialising Audio Output!\n\nTry a different Output device and please post your client log to the support Discord server.\n\nJoin support Discord server now?",
"Audio Output Error",
"JOIN DISCORD SERVER",
"CLOSE",
MessageBoxImage.Error);

if (messageBoxResult == MessageBoxResult.Yes)
{
Process.Start("https://discord.gg/baw7g3t");
}

Environment.Exit(1);
}

Expand Down Expand Up @@ -140,10 +149,39 @@ public void StartPreview(int mic, MMDevice speakers)
{
Logger.Error(ex, "Error starting audio Input - Quitting! " + ex.Message);

MessageBox.Show(
$"Problem Initialising Audio Input! Try a different Input device and please post your client log on the forums",
"Audio Input Error", MessageBoxButton.OK,
MessageBoxImage.Error);
if (Environment.OSVersion.Version.Major == 10)
{
var messageBoxResult = CustomMessageBox.ShowYesNoCancel(
"Problem initialising Audio Input!\n\nIf you are using Windows 10, this could be caused by your privacy settings (make sure to allow apps to access your microphone).\nAlternatively, try a different Input device and please post your client log to the support Discord server.",
"Audio Input Error",
"OPEN PRIVACY SETTINGS",
"JOIN DISCORD SERVER",
"CLOSE",
MessageBoxImage.Error);

if (messageBoxResult == MessageBoxResult.Yes)
{
Process.Start("ms-settings:privacy-microphone");
}
else if (messageBoxResult == MessageBoxResult.No)
{
Process.Start("https://discord.gg/baw7g3t");
}
}
else
{
var messageBoxResult = CustomMessageBox.ShowYesNo(
"Problem initialising Audio Input!\n\nTry a different Input device and please post your client log to the support Discord server.",
"Audio Input Error",
"JOIN DISCORD SERVER",
"CLOSE",
MessageBoxImage.Error);

if (messageBoxResult == MessageBoxResult.Yes)
{
Process.Start("https://discord.gg/baw7g3t");
}
}

Environment.Exit(1);
}
Expand Down
Loading

0 comments on commit 41d38e4

Please sign in to comment.