Skip to content

Commit

Permalink
Must not use AdjustedPosition when playback is paused.
Browse files Browse the repository at this point in the history
  • Loading branch information
goddogthedoggod committed Jan 29, 2020
1 parent c3327b9 commit 12c2d9a
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions NAudio/Wave/WaveOutputs/WasapiOut.cs
Original file line number Diff line number Diff line change
Expand Up @@ -270,12 +270,19 @@ private WaveFormat GetFallbackFormat()
/// <returns>Position in bytes</returns>
public long GetPosition()
{
if (playbackState == PlaybackState.Stopped)
ulong pos;
switch (playbackState)
{
return 0;
case PlaybackState.Stopped:
return 0;
case PlaybackState.Playing:
pos = audioClient.AudioClockClient.AdjustedPosition;
break;
default: // PlaybackState.Paused
audioClient.AudioClockClient.GetPosition(out pos, out _);
break;
}
var clock = audioClient.AudioClockClient;
return ((long)clock.AdjustedPosition * outputFormat.AverageBytesPerSecond) / (long)clock.Frequency;
return ((long)pos * outputFormat.AverageBytesPerSecond) / (long)audioClient.AudioClockClient.Frequency;
}

/// <summary>
Expand Down

0 comments on commit 12c2d9a

Please sign in to comment.