Skip to content

Commit

Permalink
Made _activeBuffers volatile witin the WaveOut class. This is done be…
Browse files Browse the repository at this point in the history
…cause the WaitForBuffersToFinish was getting stuck in a hard loop based on the _activeBuffers not being volatile.
  • Loading branch information
jbarber3388 committed Jun 3, 2019
1 parent 91913da commit 9b59424
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions CSCore/SoundOut/WaveOut.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class WaveOut : ISoundOut
private readonly WaveCallback _callback;
private readonly Queue<int> _failedBuffers = new Queue<int>();
private readonly object _lockObject = new object();
private int _activeBuffers;
private volatile int _activeBuffers;
private WaveOutBuffer[] _buffers;
private Thread _callbackThread;
private WaveOutDevice _device;
Expand Down Expand Up @@ -465,7 +465,6 @@ private void StopFromCallback(Exception exception)

private void WaitForBuffersToFinish()
{
//do we have volatile to _activeBuffers???
while (Interlocked.CompareExchange(ref _activeBuffers, 0, 0) != 0 && PlaybackState != PlaybackState.Stopped)
{
Thread.Sleep(10);
Expand Down

0 comments on commit 9b59424

Please sign in to comment.