revise Stop to Stop and StopImmediate
parent
4d9d3e6422
commit
1aeb3e9f6c
|
@ -12,7 +12,7 @@ namespace MoonWorks.Audio
|
||||||
|
|
||||||
public bool Is3D { get; protected set; }
|
public bool Is3D { get; protected set; }
|
||||||
|
|
||||||
public abstract SoundState State { get; protected set; }
|
public virtual SoundState State { get; protected set; }
|
||||||
|
|
||||||
private float _pan = 0;
|
private float _pan = 0;
|
||||||
public float Pan
|
public float Pan
|
||||||
|
@ -238,7 +238,8 @@ namespace MoonWorks.Audio
|
||||||
|
|
||||||
public abstract void Play();
|
public abstract void Play();
|
||||||
public abstract void Pause();
|
public abstract void Pause();
|
||||||
public abstract void Stop(bool immediate);
|
public abstract void Stop();
|
||||||
|
public abstract void StopImmediate();
|
||||||
|
|
||||||
private void InitDSPSettings(uint srcChannels)
|
private void InitDSPSettings(uint srcChannels)
|
||||||
{
|
{
|
||||||
|
@ -341,8 +342,7 @@ namespace MoonWorks.Audio
|
||||||
|
|
||||||
protected override void Destroy()
|
protected override void Destroy()
|
||||||
{
|
{
|
||||||
Stop(true);
|
StopImmediate();
|
||||||
|
|
||||||
FAudio.FAudioVoice_DestroyVoice(Handle);
|
FAudio.FAudioVoice_DestroyVoice(Handle);
|
||||||
Marshal.FreeHGlobal(dspSettings.pMatrixCoefficients);
|
Marshal.FreeHGlobal(dspSettings.pMatrixCoefficients);
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,7 @@ namespace MoonWorks.Audio
|
||||||
);
|
);
|
||||||
if (state.BuffersQueued == 0)
|
if (state.BuffersQueued == 0)
|
||||||
{
|
{
|
||||||
Stop(true);
|
StopImmediate();
|
||||||
}
|
}
|
||||||
|
|
||||||
return _state;
|
return _state;
|
||||||
|
@ -79,18 +79,17 @@ namespace MoonWorks.Audio
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Stop(bool immediate = true)
|
public override void Stop()
|
||||||
{
|
{
|
||||||
if (immediate)
|
FAudio.FAudioSourceVoice_ExitLoop(Handle, 0);
|
||||||
{
|
State = SoundState.Stopped;
|
||||||
FAudio.FAudioSourceVoice_Stop(Handle, 0, 0);
|
}
|
||||||
FAudio.FAudioSourceVoice_FlushSourceBuffers(Handle);
|
|
||||||
State = SoundState.Stopped;
|
public override void StopImmediate()
|
||||||
}
|
{
|
||||||
else
|
FAudio.FAudioSourceVoice_Stop(Handle, 0, 0);
|
||||||
{
|
FAudio.FAudioSourceVoice_FlushSourceBuffers(Handle);
|
||||||
FAudio.FAudioSourceVoice_ExitLoop(Handle, 0);
|
State = SoundState.Stopped;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Seek(uint sampleFrame)
|
public void Seek(uint sampleFrame)
|
||||||
|
|
|
@ -51,14 +51,16 @@ namespace MoonWorks.Audio
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Stop(bool immediate = true)
|
public override void Stop()
|
||||||
{
|
{
|
||||||
if (immediate)
|
State = SoundState.Stopped;
|
||||||
{
|
}
|
||||||
FAudio.FAudioSourceVoice_Stop(Handle, 0, 0);
|
|
||||||
FAudio.FAudioSourceVoice_FlushSourceBuffers(Handle);
|
public override void StopImmediate()
|
||||||
ClearBuffers();
|
{
|
||||||
}
|
FAudio.FAudioSourceVoice_Stop(Handle, 0, 0);
|
||||||
|
FAudio.FAudioSourceVoice_FlushSourceBuffers(Handle);
|
||||||
|
ClearBuffers();
|
||||||
|
|
||||||
State = SoundState.Stopped;
|
State = SoundState.Stopped;
|
||||||
}
|
}
|
||||||
|
@ -157,7 +159,7 @@ namespace MoonWorks.Audio
|
||||||
|
|
||||||
protected virtual void OnReachedEnd()
|
protected virtual void OnReachedEnd()
|
||||||
{
|
{
|
||||||
Stop(false);
|
Stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected unsafe abstract void AddBuffer(
|
protected unsafe abstract void AddBuffer(
|
||||||
|
@ -169,7 +171,7 @@ namespace MoonWorks.Audio
|
||||||
|
|
||||||
protected override void Destroy()
|
protected override void Destroy()
|
||||||
{
|
{
|
||||||
Stop(true);
|
StopImmediate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,8 +16,6 @@ namespace MoonWorks.Audio
|
||||||
|
|
||||||
private readonly float[] buffer; // currently decoded bytes
|
private readonly float[] buffer; // currently decoded bytes
|
||||||
|
|
||||||
public override SoundState State { get; protected set; }
|
|
||||||
|
|
||||||
public unsafe static StreamingSoundOgg Load(AudioDevice device, string filePath)
|
public unsafe static StreamingSoundOgg Load(AudioDevice device, string filePath)
|
||||||
{
|
{
|
||||||
var fileData = File.ReadAllBytes(filePath);
|
var fileData = File.ReadAllBytes(filePath);
|
||||||
|
|
|
@ -18,7 +18,7 @@ namespace MoonWorks.Audio
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Stop(false);
|
Stop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,9 +5,7 @@ namespace MoonWorks.Video
|
||||||
{
|
{
|
||||||
public unsafe class StreamingSoundTheora : StreamingSound
|
public unsafe class StreamingSoundTheora : StreamingSound
|
||||||
{
|
{
|
||||||
public IntPtr VideoHandle;
|
private IntPtr VideoHandle;
|
||||||
|
|
||||||
public override SoundState State { get => throw new System.NotImplementedException(); protected set => throw new System.NotImplementedException(); }
|
|
||||||
|
|
||||||
public override int BUFFER_SIZE => 4096 * 2;
|
public override int BUFFER_SIZE => 4096 * 2;
|
||||||
|
|
||||||
|
|
|
@ -195,7 +195,7 @@ namespace MoonWorks.Video
|
||||||
|
|
||||||
if (audioStream != null)
|
if (audioStream != null)
|
||||||
{
|
{
|
||||||
audioStream.Stop(true);
|
audioStream.StopImmediate();
|
||||||
audioStream.Dispose();
|
audioStream.Dispose();
|
||||||
audioStream = null;
|
audioStream = null;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue