fix: make sure threads actually return

This commit is contained in:
Anna 2020-12-30 14:20:42 -05:00
parent cb6bb92979
commit c305ff1a7f

View File

@ -201,19 +201,20 @@ namespace PeepingTom {
} else { } else {
reader = new AudioFileReader(this.Plugin.Config.SoundPath); reader = new AudioFileReader(this.Plugin.Config.SoundPath);
} }
#pragma warning disable CA1031 // Do not catch general exception types
} catch (Exception e) { } catch (Exception e) {
#pragma warning restore CA1031 // Do not catch general exception types
this.SendError($"Could not play sound file: {e.Message}"); this.SendError($"Could not play sound file: {e.Message}");
return; return;
} }
using WaveChannel32 channel = new WaveChannel32(reader) { using WaveChannel32 channel = new WaveChannel32(reader) {
Volume = this.Plugin.Config.SoundVolume, Volume = this.Plugin.Config.SoundVolume,
PadWithZeroes = false,
}; };
using (reader) { using (reader) {
using var output = new WaveOutEvent {DeviceNumber = soundDevice}; using var output = new WaveOutEvent {
DeviceNumber = soundDevice,
};
output.Init(channel); output.Init(channel);
output.Play(); output.Play();
@ -228,7 +229,10 @@ namespace PeepingTom {
Payload[] payloads = { Payload[] payloads = {
new TextPayload($"[{this.Plugin.Name}] {message}"), new TextPayload($"[{this.Plugin.Name}] {message}"),
}; };
this.Plugin.Interface.Framework.Gui.Chat.PrintChat(new XivChatEntry {MessageBytes = new SeString(payloads).Encode(), Type = XivChatType.ErrorMessage,}); this.Plugin.Interface.Framework.Gui.Chat.PrintChat(new XivChatEntry {
MessageBytes = new SeString(payloads).Encode(),
Type = XivChatType.ErrorMessage,
});
} }
public void Dispose() { public void Dispose() {