fix: make sure to dispose channel

This commit is contained in:
Anna 2020-12-29 11:11:32 -05:00
parent 71ecb7b3af
commit 7c796a339a
1 changed files with 8 additions and 7 deletions

View File

@ -208,16 +208,17 @@ namespace PeepingTom {
return;
}
WaveChannel32 channel = new WaveChannel32(reader) {Volume = this.Plugin.Config.SoundVolume,};
using WaveChannel32 channel = new WaveChannel32(reader) {
Volume = this.Plugin.Config.SoundVolume,
};
using (reader) {
using (var output = new WaveOutEvent() {DeviceNumber = soundDevice}) {
output.Init(channel);
output.Play();
using var output = new WaveOutEvent {DeviceNumber = soundDevice};
output.Init(channel);
output.Play();
while (output.PlaybackState == PlaybackState.Playing) {
Thread.Sleep(500);
}
while (output.PlaybackState == PlaybackState.Playing) {
Thread.Sleep(500);
}
}
}).Start();