rename OnBufferNeeded to OnSoundNeeded

pull/50/head
cosmonaut 2023-07-28 13:10:01 -07:00
parent 1d86d0c210
commit 83f1cc24db
1 changed files with 8 additions and 10 deletions

View File

@ -2,14 +2,12 @@ using System;
namespace MoonWorks.Audio namespace MoonWorks.Audio
{ {
// NOTE: all sounds played with a playlist must have the same audio format! // NOTE: all sounds played with a SoundQueue must have the same audio format!
public class SoundQueue : SoundInstance public class SoundQueue : SoundInstance
{ {
public int NeedBufferThreshold = 0; public int NeedSoundThreshold = 0;
private uint queuedBufferCount = 0; public delegate void OnSoundNeededFunc();
public OnSoundNeededFunc OnSoundNeeded;
public delegate void OnBufferNeededFunc();
public OnBufferNeededFunc OnBufferNeeded;
private object StateLock = new object(); private object StateLock = new object();
@ -30,7 +28,7 @@ namespace MoonWorks.Audio
if (IsDisposed) { return; } if (IsDisposed) { return; }
if (State != SoundState.Playing) { return; } if (State != SoundState.Playing) { return; }
if (NeedBufferThreshold > 0) if (NeedSoundThreshold > 0)
{ {
FAudio.FAudioSourceVoice_GetState( FAudio.FAudioSourceVoice_GetState(
Voice, Voice,
@ -39,11 +37,11 @@ namespace MoonWorks.Audio
); );
var queuedBufferCount = state.BuffersQueued; var queuedBufferCount = state.BuffersQueued;
for (int i = 0; i < NeedBufferThreshold - queuedBufferCount; i += 1) for (int i = 0; i < NeedSoundThreshold - queuedBufferCount; i += 1)
{ {
if (OnBufferNeeded != null) if (OnSoundNeeded != null)
{ {
OnBufferNeeded(); OnSoundNeeded();
} }
} }
} }