Class DynamicSoundSource
public abstract class DynamicSoundSource : IDisposable
- Inheritance
-
DynamicSoundSource
- Implements
- Derived
- Extension Methods
Constructors
DynamicSoundSource(SoundInstance, int, int)
Initializes a new instance of the DynamicSoundSource class. Sub classes can implement their own streaming sources.
protected DynamicSoundSource(SoundInstance soundInstance, int numberOfBuffers, int maxBufferSizeBytes)
Parameters
soundInstance
SoundInstancethe sound instance associated.
numberOfBuffers
intthe size of the streaming ring-buffer.
maxBufferSizeBytes
intthe maximum size of each buffer.
Fields
Commands
The commands derived classes should execute.
protected readonly ConcurrentQueue<DynamicSoundSource.AsyncCommand> Commands
Field Value
Logger
public static Logger Logger
Field Value
NewSources
protected static readonly ConcurrentBag<DynamicSoundSource> NewSources
Field Value
Sources
protected static readonly List<DynamicSoundSource> Sources
Field Value
deviceBuffers
protected readonly List<AudioLayer.Buffer> deviceBuffers
Field Value
freeBuffers
protected readonly Queue<AudioLayer.Buffer> freeBuffers
Field Value
isDisposed
protected bool isDisposed
Field Value
isInitialized
protected bool isInitialized
Field Value
playingQueued
If we are waiting to play.
protected volatile bool playingQueued
Field Value
soundInstance
The sound instance associated.
protected SoundInstance soundInstance
Field Value
state
If we are in the paused state.
protected PlayState state
Field Value
Properties
CanFill
Checks if a buffer can be filled, before calling FillBuffer this should be checked.
protected virtual bool CanFill { get; }
Property Value
Ended
Gets a task that will be fired once there will be no more queueud data.
public TaskCompletionSource<bool> Ended { get; }
Property Value
IsPausedOrPlaying
Gets if this instance is in the playing state.
public bool IsPausedOrPlaying { get; }
Property Value
MaxNumberOfBuffers
Max number of buffers that are going to be queued.
public abstract int MaxNumberOfBuffers { get; }
Property Value
PlayRange
Gets or sets the region of time to play from the audio clip.
public virtual PlayRange PlayRange { get; set; }
Property Value
ReadyToPlay
Gets a task that will be fired once the source is ready to play.
public TaskCompletionSource<bool> ReadyToPlay { get; }
Property Value
Methods
Dispose()
Enqueues a dispose command, to dispose this instance.
public virtual void Dispose()
DisposeInternal()
Destroys the instance.
protected virtual void DisposeInternal()
ExtractAndFillData()
protected abstract void ExtractAndFillData()
FillBuffer(byte[], int, BufferType)
If CanFillis true with this method you can fill the next free buffer
protected void FillBuffer(byte[] pcm, int bufferSize, AudioLayer.BufferType type)
Parameters
pcm
byte[]The array containing PCM data
bufferSize
intThe full size in bytes of PCM data
type
AudioLayer.BufferTypeIf this buffer is the last buffer of the stream set to true, if not false
FillBuffer(short[], int, BufferType)
If CanFillis true with this method you can fill the next free buffer
protected void FillBuffer(short[] pcm, int bufferSize, AudioLayer.BufferType type)
Parameters
pcm
short[]The array containing PCM data
bufferSize
intThe full size in bytes of PCM data
type
AudioLayer.BufferTypeIf this buffer is the last buffer of the stream set to true, if not false
FillBuffer(nint, int, BufferType)
If CanFillis true with this method you can fill the next free buffer
protected void FillBuffer(nint pcm, int bufferSize, AudioLayer.BufferType type)
Parameters
pcm
nintThe pointer to PCM data
bufferSize
intThe full size in bytes of PCM data
type
AudioLayer.BufferTypeIf this buffer is the last buffer of the stream set to true, if not false
InitializeInternal()
protected virtual void InitializeInternal()
Pause()
Enqueues a Pause command, to Pause this instance.
public void Pause()
PauseInternal()
protected virtual void PauseInternal()
Play()
Enqueues a Play command, to Play this instance.
public void Play()
PlayInternal()
protected virtual void PlayInternal()
PrepareInternal()
Prepare the source for playback
protected virtual void PrepareInternal()
RestartInternal()
Restarts streaming from the beginning.
protected virtual void RestartInternal()
SeekInternal()
protected virtual void SeekInternal()
SetLooped(bool)
Sets if the stream should be played in loop.
public abstract void SetLooped(bool looped)
Parameters
looped
boolif looped or not
Stop()
Enqueues a Stop command, to Stop this instance.
public void Stop()
StopInternal(bool)
protected virtual void StopInternal(bool ignoreQueuedBuffer = true)
Parameters
ignoreQueuedBuffer
bool
UpdateInternal()
Update the sound source
protected virtual void UpdateInternal()