1
0
mirror of https://github.com/Artemis-RGB/Artemis synced 2026-01-01 02:03:32 +00:00

Catch and log WASAPI error

This commit is contained in:
SpoinkyNL 2016-10-25 18:34:58 +02:00
parent 2073c5fdea
commit fb558a1057
3 changed files with 16 additions and 5 deletions

View File

@ -128,7 +128,7 @@ namespace Artemis.DAL
if (Profiles.Any(p => p.GameName == prof.GameName && p.Name == prof.Name && if (Profiles.Any(p => p.GameName == prof.GameName && p.Name == prof.Name &&
p.KeyboardSlug == prof.KeyboardSlug)) p.KeyboardSlug == prof.KeyboardSlug))
{ {
Logger.Error("Didn't load duplicate profile: {0}", path); Logger.Info("Didn't load duplicate profile: {0}", path);
} }
else else
{ {

View File

@ -15,6 +15,7 @@ using Artemis.ViewModels.Profiles;
using NAudio.CoreAudioApi; using NAudio.CoreAudioApi;
using NAudio.Wave; using NAudio.Wave;
using Newtonsoft.Json; using Newtonsoft.Json;
using NLog;
namespace Artemis.Profiles.Layers.Types.Audio namespace Artemis.Profiles.Layers.Types.Audio
{ {
@ -24,6 +25,7 @@ namespace Artemis.Profiles.Layers.Types.Audio
private readonly MMDevice _device; private readonly MMDevice _device;
private readonly SampleAggregator _sampleAggregator = new SampleAggregator(1024); private readonly SampleAggregator _sampleAggregator = new SampleAggregator(1024);
private readonly WasapiLoopbackCapture _waveIn; private readonly WasapiLoopbackCapture _waveIn;
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
private int _lines; private int _lines;
private AudioPropertiesModel _previousSettings; private AudioPropertiesModel _previousSettings;
@ -38,7 +40,16 @@ namespace Artemis.Profiles.Layers.Types.Audio
// Start listening for sound data // Start listening for sound data
_waveIn = new WasapiLoopbackCapture(); _waveIn = new WasapiLoopbackCapture();
_waveIn.DataAvailable += OnDataAvailable; _waveIn.DataAvailable += OnDataAvailable;
_waveIn.StartRecording();
try
{
_waveIn.StartRecording();
}
catch (Exception e)
{
Logger.Warn(e, "Failed to start WASAPI audio capture");
throw;
}
} }
[JsonIgnore] [JsonIgnore]

View File

@ -60,8 +60,8 @@ namespace Artemis.Utilities
{ {
var settings = SettingsProvider.Load<GeneralSettings>(); var settings = SettingsProvider.Load<GeneralSettings>();
var currentVersion = Assembly.GetExecutingAssembly().GetName().Version; var currentVersion = Assembly.GetExecutingAssembly().GetName().Version;
// if ((settings.LastRanVersion != null) && (currentVersion > settings.LastRanVersion)) if ((settings.LastRanVersion != null) && (currentVersion > settings.LastRanVersion))
// { {
Logger.Info("Updated from {0} to {1}, showing changelog.", settings.LastRanVersion, currentVersion); Logger.Info("Updated from {0} to {1}, showing changelog.", settings.LastRanVersion, currentVersion);
// Ask the user whether he/she wants to see what's new // Ask the user whether he/she wants to see what's new
@ -73,7 +73,7 @@ namespace Artemis.Utilities
// If user wants to see changelog, show it to them // If user wants to see changelog, show it to them
if ((showChanges != null) && showChanges.Value) if ((showChanges != null) && showChanges.Value)
await ShowChanges(dialogService, currentVersion); await ShowChanges(dialogService, currentVersion);
// } }
settings.LastRanVersion = currentVersion; settings.LastRanVersion = currentVersion;
settings.Save(); settings.Save();