forked from MoonsideGames/MoonWorks
Add synchronized audio playback mechanism
parent
5baa1d7b40
commit
e9aacb44da
|
@ -224,6 +224,11 @@ namespace MoonWorks.Audio
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void SyncPlay()
|
||||||
|
{
|
||||||
|
FAudio.FAudio_CommitChanges(Handle, 1);
|
||||||
|
}
|
||||||
|
|
||||||
internal void AddDynamicSoundInstance(StreamingSound instance)
|
internal void AddDynamicSoundInstance(StreamingSound instance)
|
||||||
{
|
{
|
||||||
streamingSounds.Add(new WeakReference<StreamingSound>(instance));
|
streamingSounds.Add(new WeakReference<StreamingSound>(instance));
|
||||||
|
|
|
@ -253,6 +253,7 @@ namespace MoonWorks.Audio
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract void Play();
|
public abstract void Play();
|
||||||
|
public abstract void QueueSyncPlay();
|
||||||
public abstract void Pause();
|
public abstract void Pause();
|
||||||
public abstract void Stop();
|
public abstract void Stop();
|
||||||
public abstract void StopImmediate();
|
public abstract void StopImmediate();
|
||||||
|
|
|
@ -41,6 +41,16 @@ namespace MoonWorks.Audio
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Play()
|
public override void Play()
|
||||||
|
{
|
||||||
|
PlayUsingOperationSet(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void QueueSyncPlay()
|
||||||
|
{
|
||||||
|
PlayUsingOperationSet(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void PlayUsingOperationSet(uint operationSet)
|
||||||
{
|
{
|
||||||
if (State == SoundState.Playing)
|
if (State == SoundState.Playing)
|
||||||
{
|
{
|
||||||
|
@ -66,7 +76,7 @@ namespace MoonWorks.Audio
|
||||||
IntPtr.Zero
|
IntPtr.Zero
|
||||||
);
|
);
|
||||||
|
|
||||||
FAudio.FAudioSourceVoice_Start(Handle, 0, 0);
|
FAudio.FAudioSourceVoice_Start(Handle, 0, operationSet);
|
||||||
State = SoundState.Playing;
|
State = SoundState.Playing;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -35,6 +35,16 @@ namespace MoonWorks.Audio
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Play()
|
public override void Play()
|
||||||
|
{
|
||||||
|
PlayUsingOperationSet(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void QueueSyncPlay()
|
||||||
|
{
|
||||||
|
PlayUsingOperationSet(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void PlayUsingOperationSet(uint operationSet)
|
||||||
{
|
{
|
||||||
if (State == SoundState.Playing)
|
if (State == SoundState.Playing)
|
||||||
{
|
{
|
||||||
|
@ -44,7 +54,7 @@ namespace MoonWorks.Audio
|
||||||
State = SoundState.Playing;
|
State = SoundState.Playing;
|
||||||
|
|
||||||
Update();
|
Update();
|
||||||
FAudio.FAudioSourceVoice_Start(Handle, 0, 0);
|
FAudio.FAudioSourceVoice_Start(Handle, 0, operationSet);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Pause()
|
public override void Pause()
|
||||||
|
|
Loading…
Reference in New Issue