This object is the base class for audio ringbuffers used by the base audio source and sink classes.
The ringbuffer abstracts a circular buffer of data. One reader and one writer can operate on the data from different threads in a
lockfree manner. The base class is sufficiently flexible to be used as an abstraction for DMA based ringbuffers as well as a pure software
implementations.
- public virtual bool acquire (RingBufferSpec spec)
Allocate the resources for the ringbuffer.
- public virtual bool activate (bool active)
Activate this to start or stop
pulling data.
- public void advance (uint advance)
Subclasses should call this function to notify the fact that
advance segments are now processed by the device.
- public void clear (int segment)
Clear the given segment of the buffer with silence samples.
- public virtual void clear_all ()
Clear all samples from the ringbuffer.
- public virtual bool close_device ()
Close the audio device associated with the ring buffer.
- public virtual uint commit (ref uint64 sample, uint8[] data, int out_samples, ref int accum)
Commit data.length samples pointed to by data
to the ringbuffer this.
- public bool convert (Format src_fmt, int64 src_val, Format dest_fmt, out int64 dest_val)
Convert src_val in src_fmt to the equivalent
value in dest_fmt.
- public virtual uint delay ()
Get the number of samples queued in the audio device.
- public bool device_is_open ()
Checks the status of the device associated with the ring buffer.
- public bool is_acquired ()
Check if the ringbuffer is acquired and ready to use.
- public bool is_active ()
Check if this is activated.
- public bool is_flushing ()
Check if this is flushing.
- public void may_start (bool allowed)
Tell the ringbuffer that it is allowed to start playback when the
ringbuffer is filled with samples.
- public virtual bool open_device ()
Open the audio device associated with the ring buffer.
- public virtual bool pause ()
Pause processing samples from the ringbuffer.
- public bool prepare_read (out int segment, out uint8[] readptr)
Returns a pointer to memory where the data from segment segment
can be found.
- public uint read (uint64 sample, uint8[] data, out ClockTime timestamp)
Read data.length samples from the ringbuffer into the
memory pointed to by data.
- public virtual bool release ()
Free the resources of the ringbuffer.
- public virtual bool resume ()
resume processing of samples after pause
- public uint64 samples_done ()
Get the number of samples that were processed by the ringbuffer since
it was last started.
- public void set_callback_full (owned RingBufferCallback? cb)
Sets the given callback function on the buffer.
- public void set_channel_positions (ChannelPosition[] position)
Tell the ringbuffer about the device's channel positions.
- public void set_flushing (bool flushing)
Set the ringbuffer to flushing mode or normal mode.
- public void set_sample (uint64 sample)
Make sure that the next sample written to the device is accounted for
as being the sample sample written to the device.
- public void set_timestamp (int readseg, ClockTime timestamp)
- public virtual bool start ()
Start processing samples from the ringbuffer.
- public virtual bool stop ()
Stop processing samples from the ringbuffer.