This project has moved. For the latest updates, please go here.

Found a bug with PlaybackStopped in WaveOutEvent

Feb 5, 2014 at 7:07 AM
When the audio finishes and triggers OnPlaybackStopped, calling Play() again shortly after doesn't play the audio.

To get it going again you need to call Pause() then Play() again. The PlaybackState = Playing, but no audio and no audio position change.

This can be replicated in the NAudioWpfDemo.exe > MediaFoundation Playback, and also when using ACM. Replicated with mp3, wav, and aac files.

        private void OnPlaybackStopped(object sender, StoppedEventArgs stoppedEventArgs)
Feb 5, 2014 at 7:11 AM
hmm, could be this. I meant to get that bugfix into NAudio 1.7 but never got round to it.
Feb 5, 2014 at 7:25 AM
Yep that fixed it, cant fault it whatever I do now.
                if (queued == 0)
                    // we got to the end
                    this.playbackState = PlaybackState.Stopped;

                    callbackEvent.Set();          <<<<<<< just added this line.
Feb 5, 2014 at 10:16 AM
great, this fix is in now. thanks for reporting & testing

ps I haven't forgotten about your pull request. Just need a bit of time to properly review it and think through implications of changing WaveFormatExtraData
Feb 5, 2014 at 10:28 AM
Ok no worries, thanks. NAudio doesn't seem to use it anywhere but I suppose others may be using it in their app, or it simply wasn't byte aligned properly all along, or MediaFoundation is extra picky.