Skip to content

Commit 338f75d

Browse files
authored
Fixed SoundEffectInstance looping under XAudio (MonoGame#8748)
Fixed SoundEffectInstance looping under XAudio as reported in MonoGame#8711.
1 parent 8ef655d commit 338f75d

File tree

1 file changed

+3
-14
lines changed

1 file changed

+3
-14
lines changed

MonoGame.Framework/Platform/Audio/SoundEffectInstance.XAudio.cs

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ public partial class SoundEffectInstance : IDisposable
2424
private float _reverbMix;
2525

2626
private bool _paused;
27-
private bool _loop;
2827

2928
private void PlatformInitialize(byte[] buffer, int sampleRate, int channels)
3029
{
@@ -162,7 +161,7 @@ private void PlatformPlay()
162161
if (_voice != null && SoundEffect.MasterVoice != null)
163162
{
164163
// Choose the correct buffer depending on if we are looped.
165-
var buffer = _loop ? _effect._loopedBuffer : _effect._buffer;
164+
var buffer = _isLooped ? _effect._loopedBuffer : _effect._buffer;
166165

167166
if (_voice.State.BuffersQueued > 0)
168167
{
@@ -182,7 +181,7 @@ private void PlatformResume()
182181
if (_voice != null && SoundEffect.MasterVoice != null)
183182
{
184183
// Restart the sound if (and only if) it stopped playing
185-
if (!_loop)
184+
if (!_isLooped)
186185
{
187186
if (_voice.State.BuffersQueued == 0)
188187
{
@@ -207,7 +206,7 @@ private void PlatformStop(bool immediate)
207206
}
208207
else
209208
{
210-
if (_loop)
209+
if (_isLooped)
211210
_voice.ExitLoop();
212211
else
213212
_voice.Stop((int)PlayFlags.Tails);
@@ -217,16 +216,6 @@ private void PlatformStop(bool immediate)
217216
_paused = false;
218217
}
219218

220-
private void PlatformSetIsLooped(bool value)
221-
{
222-
_loop = value;
223-
}
224-
225-
private bool PlatformGetIsLooped()
226-
{
227-
return _loop;
228-
}
229-
230219
private void PlatformSetPan(float value)
231220
{
232221
// According to XNA documentation:

0 commit comments

Comments
 (0)