Skip to content

Commit

Permalink
Merge pull request #610 from DexterHaslem/dc-freeze
Browse files Browse the repository at this point in the history
fix potential freezes and crashes in instant connect/disconnect edge case
  • Loading branch information
ciribob authored Jun 22, 2022
2 parents 75ae74c + 42f8751 commit 7e17c11
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions NAudio/Wave/WaveInputs/WasapiCapture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,8 @@ private void CaptureThread(AudioClient client)
client.Stop();
// don't dispose - the AudioClient only gets disposed when WasapiCapture is disposed
}
captureThread = null;
// dont nuke our captureThread reference here, dispose also checks it
// captureThread = null;
captureState = CaptureState.Stopped;
RaiseRecordingStopped(exception);
}
Expand Down Expand Up @@ -356,7 +357,11 @@ public void Dispose()
StopRecording();
if (captureThread != null)
{
captureThread.Join();
if (captureThread.IsAlive)
{
captureThread.Abort();
captureThread.Join();
}
captureThread = null;
}
if (audioClient != null)
Expand Down

0 comments on commit 7e17c11

Please sign in to comment.