revise Stop to Stop and StopImmediate

pull/20/head
cosmonaut 2022-08-01 23:14:45 -07:00
parent 4d9d3e6422
commit 1aeb3e9f6c
7 changed files with 29 additions and 32 deletions

View File

@ -12,7 +12,7 @@ namespace MoonWorks.Audio
public bool Is3D { get; protected set; }
public abstract SoundState State { get; protected set; }
public virtual SoundState State { get; protected set; }
private float _pan = 0;
public float Pan
@ -238,7 +238,8 @@ namespace MoonWorks.Audio
public abstract void Play();
public abstract void Pause();
public abstract void Stop(bool immediate);
public abstract void Stop();
public abstract void StopImmediate();
private void InitDSPSettings(uint srcChannels)
{
@ -341,8 +342,7 @@ namespace MoonWorks.Audio
protected override void Destroy()
{
Stop(true);
StopImmediate();
FAudio.FAudioVoice_DestroyVoice(Handle);
Marshal.FreeHGlobal(dspSettings.pMatrixCoefficients);
}

View File

@ -20,7 +20,7 @@ namespace MoonWorks.Audio
);
if (state.BuffersQueued == 0)
{
Stop(true);
StopImmediate();
}
return _state;
@ -79,19 +79,18 @@ namespace MoonWorks.Audio
}
}
public override void Stop(bool immediate = true)
public override void Stop()
{
if (immediate)
FAudio.FAudioSourceVoice_ExitLoop(Handle, 0);
State = SoundState.Stopped;
}
public override void StopImmediate()
{
FAudio.FAudioSourceVoice_Stop(Handle, 0, 0);
FAudio.FAudioSourceVoice_FlushSourceBuffers(Handle);
State = SoundState.Stopped;
}
else
{
FAudio.FAudioSourceVoice_ExitLoop(Handle, 0);
}
}
public void Seek(uint sampleFrame)
{

View File

@ -51,14 +51,16 @@ namespace MoonWorks.Audio
}
}
public override void Stop(bool immediate = true)
public override void Stop()
{
if (immediate)
State = SoundState.Stopped;
}
public override void StopImmediate()
{
FAudio.FAudioSourceVoice_Stop(Handle, 0, 0);
FAudio.FAudioSourceVoice_FlushSourceBuffers(Handle);
ClearBuffers();
}
State = SoundState.Stopped;
}
@ -157,7 +159,7 @@ namespace MoonWorks.Audio
protected virtual void OnReachedEnd()
{
Stop(false);
Stop();
}
protected unsafe abstract void AddBuffer(
@ -169,7 +171,7 @@ namespace MoonWorks.Audio
protected override void Destroy()
{
Stop(true);
StopImmediate();
}
}
}

View File

@ -16,8 +16,6 @@ namespace MoonWorks.Audio
private readonly float[] buffer; // currently decoded bytes
public override SoundState State { get; protected set; }
public unsafe static StreamingSoundOgg Load(AudioDevice device, string filePath)
{
var fileData = File.ReadAllBytes(filePath);

View File

@ -18,7 +18,7 @@ namespace MoonWorks.Audio
}
else
{
Stop(false);
Stop();
}
}
}

View File

@ -5,9 +5,7 @@ namespace MoonWorks.Video
{
public unsafe class StreamingSoundTheora : StreamingSound
{
public IntPtr VideoHandle;
public override SoundState State { get => throw new System.NotImplementedException(); protected set => throw new System.NotImplementedException(); }
private IntPtr VideoHandle;
public override int BUFFER_SIZE => 4096 * 2;

View File

@ -195,7 +195,7 @@ namespace MoonWorks.Video
if (audioStream != null)
{
audioStream.Stop(true);
audioStream.StopImmediate();
audioStream.Dispose();
audioStream = null;
}