gstreamermm: Gst::AudioRingBuffer Class Reference
A base class for audio audioringbuffer implementations. More...


Public Types | |
| typedef sigc::slot< void, const Glib::ArrayHandle < guint8 >&, guint > | SlotFill |
| For example, bool on_fill(const Glib::RefPtr<Gst::AudioRingBuffer>& rbuf, const std::vector<guint8>& data, guint len);. More... | |
Public Member Functions | |
| virtual | ~AudioRingBuffer () |
| GstAudioRingBuffer* | gobj () |
| Provides access to the underlying C GObject. More... | |
| const GstAudioRingBuffer* | gobj () const |
| Provides access to the underlying C GObject. More... | |
| GstAudioRingBuffer* | gobj_copy () |
| Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs. More... | |
| void | set_fill_slot (const SlotFill& slot) |
| Sets the given fill slot on the buffer. More... | |
| bool | acquire (Gst::AudioRingBufferSpec& spec) |
| Allocate the resources for the ringbuffer. More... | |
| bool | release () |
| Free the resources of the ringbuffer. More... | |
| bool | is_acquired () const |
| Check if the ringbuffer is acquired and ready to use. More... | |
| bool | activate (bool active) |
| Activate buf to start or stop pulling data. More... | |
| bool | is_active () const |
| Check if buf is activated. More... | |
| bool | start () |
| Start processing samples from the ringbuffer. More... | |
| bool | pause () |
| Pause processing samples from the ringbuffer. More... | |
| bool | stop () |
| Stop processing samples from the ringbuffer. More... | |
| guint | get_delay () const |
| Get the number of samples queued in the audio device. More... | |
| guint64 | get_samples_done () const |
| Get the number of samples that were processed by the ringbuffer since it was last started. More... | |
| void | set_sample (guint64 sample) |
| Make sure that the next sample written to the device is accounted for as being the sample sample written to the device. More... | |
| void | set_channel_position (const Gst::AudioChannelPosition& position) |
| Tell the ringbuffer about the device's channel positions. More... | |
| gboolean | is_flushing () |
| Check if buf is flushing. More... | |
| void | set_timestamp (gint readseg, ClockTime timestamp) |
| guint | commit (guint64& sample, const std::vector< guint8 >& data, int in_samples, int out_samples, int& accum) |
| Commit in_samples samples pointed to by data to the ringbuffer buf. More... | |
| bool | convert (Gst::Format src_fmt, gint64 src_val, Gst::Format dest_fmt, gint64& dest_val) const |
| Convert src_val in src_fmt to the equivalent value in dest_fmt. More... | |
| bool | prepare_read (int& segment, std::vector< guint8 >& readptr, int& len) |
| Returns a pointer to memory where the data from segment segment can be found. More... | |
| guint | read (guint64 sample, const std::vector< guint8 >& data, guint len, ClockTime& timestamp) |
| Read len samples from the ringbuffer into the memory pointed to by data. More... | |
| void | clear (int segment) |
| Clear the given segment of the buffer with silence samples. More... | |
| void | clear_all () |
| Fill the ringbuffer with silence. More... | |
| void | advance (guint advance) |
| Subclasses should call this function to notify the fact that advance segments are now processed by the device. More... | |
| bool | close_device () |
| Close the audio device associated with the ring buffer. More... | |
| bool | open_device () |
| Open the audio device associated with the ring buffer. More... | |
| bool | device_is_open () const |
| Checks the status of the device associated with the ring buffer. More... | |
| void | set_may_start (bool allowed) |
| Tell the ringbuffer that it is allowed to start playback when the ringbuffer is filled with samples. More... | |
| void | set_flushing (bool flushing) |
| Set the ringbuffer to flushing mode or normal mode. More... | |
| virtual bool | open_device_vfunc () |
| Virtual function to open the device. More... | |
| virtual bool | acquire_vfunc (Gst::AudioRingBufferSpec& spec) |
| Virtual function to allocate the resources for the ring buffer using the given spec. More... | |
| virtual bool | release_vfunc () |
| Virtual function to free resources of the ring buffer. More... | |
| virtual bool | close_device_vfunc () |
| Virtual function to close the device. More... | |
| virtual bool | start_vfunc () |
| Virtual function to start processing of samples. More... | |
| virtual bool | pause_vfunc () |
| Virtual function to pause processing of samples. More... | |
| virtual bool | resume_vfunc () |
| Virtual function to resume processing of samples after pause. More... | |
| virtual bool | stop_vfunc () |
| Virtual function to stop processing of samples. More... | |
| virtual guint | delay_vfunc () |
| Virtual function to get number of samples queued in device. More... | |
| virtual bool | activate_vfunc (bool active) |
| Virtual function to activate the thread that starts pulling and monitoring the consumed segments in the device. More... | |
| virtual guint | commit_vfunc (guint64& sample, const std::vector< guint8 >& data, int in_samples, int out_samples, int& accum) |
| Virtual function to write samples into the ring buffer. More... | |
| virtual void | clear_all_vfunc () |
| Virtual function to clear the entire audioringbuffer Since 0.10.24. More... | |
Public Member Functions inherited from Gst::Object | |
| virtual | ~Object () |
| GstObject* | gobj () |
| Provides access to the underlying C GObject. More... | |
| const GstObject* | gobj () const |
| Provides access to the underlying C GObject. More... | |
| GstObject* | gobj_copy () |
| Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs. More... | |
| bool | is_element () const |
| bool | is_element_factory () const |
| bool | is_pad () const |
| bool | is_pad_template () const |
| bool | is_bin () const |
| guint32 | get_flags () const |
| Returns the entire set of flags for the object. More... | |
| bool | set_name (const Glib::ustring& name) |
Sets the name of object, or gives object a guaranteed unique name (if name is 0). More... | |
| Glib::ustring | get_name () const |
| Returns a copy of the name of object. More... | |
| bool | set_parent (const Glib::RefPtr< Gst::Object >& parent) |
| Sets the parent of object to parent. More... | |
| Glib::RefPtr< Gst::Object > | get_parent () |
| Returns the parent of object. More... | |
| Glib::RefPtr< const Gst::Object > | get_parent () const |
| Returns the parent of object. More... | |
| void | unparent () |
| Clear the parent of object, removing the associated reference. More... | |
| bool | has_ancestor (const Glib::RefPtr< const Gst::Object >& ancestor) const |
| Check if object has an ancestor ancestor somewhere up in the hierarchy. More... | |
| Glib::ustring | get_path_string () |
| Generates a string describing the path of object in the object hierarchy. More... | |
| Glib::PropertyProxy < Glib::ustring > | property_name () |
| The name of the object. More... | |
| Glib::PropertyProxy_ReadOnly < Glib::ustring > | property_name () const |
| The name of the object. More... | |
| Glib::SignalProxy2< void, const Glib::RefPtr< Object > &, GParamSpec* > | signal_deep_notify () |
| int | get_refcount () const |
Static Public Member Functions | |
| static GType | get_type () |
| Get the GType for this class, for use with the underlying GObject type system. More... | |
| static bool | parse_caps (Gst::AudioRingBufferSpec& p1, const Glib::RefPtr< Gst::Caps >& caps) |
| Parse caps into spec. More... | |
Static Public Member Functions inherited from Gst::Object | |
| static GType | get_type () |
| Get the GType for this class, for use with the underlying GObject type system. More... | |
| static bool | check_uniqueness (const Glib::ListHandle< const Gst::Object >& list, const Glib::ustring& name) |
| Checks to see if there is any object named name in list. More... | |
Related Functions | |
(Note that these are not member functions.) | |
| Glib::RefPtr < Gst::AudioRingBuffer > | wrap (GstAudioRingBuffer* object, bool take_copy=false) |
| A Glib::wrap() method for this object. More... | |
Related Functions inherited from Gst::Object | |
| Glib::RefPtr< Gst::Object > | wrap (GstObject* object, bool take_copy=false) |
| A Glib::wrap() method for this object. More... | |
Additional Inherited Members | |
Protected Member Functions inherited from Gst::Object | |
| virtual void | on_deep_notify (const Glib::RefPtr< Object >& prop_object, GParamSpec* prop) |
| This is a default handler for the signal signal_deep_notify(). More... | |
Detailed Description
A base class for audio audioringbuffer implementations.
This object is the base class for audio ringbuffers used by the base audio source and sink classes.
The audioringbuffer 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 audioringbuffer as well as a pure software implementations.
Last reviewed on 2006-02-02 (0.10.4).
Member Typedef Documentation
| typedef sigc::slot<void, const Glib::ArrayHandle<guint8>&, guint> Gst::AudioRingBuffer::SlotFill |
For example, bool on_fill(const Glib::RefPtr<Gst::AudioRingBuffer>& rbuf, const std::vector<guint8>& data, guint len);.
This slot is set with set_fill_slot() and is called to fill the memory at data with len bytes of samples.
Constructor & Destructor Documentation
|
virtual |
Member Function Documentation
| bool Gst::AudioRingBuffer::acquire | ( | Gst::AudioRingBufferSpec& | spec | ) |
Allocate the resources for the ringbuffer.
This function fills in the data pointer of the ring buffer with a valid Gst::Buffer to which samples can be written.
- Parameters
-
spec The specs of the buffer.
- Returns
trueif the device could be acquired,falseon error.
MT safe.
|
virtual |
Virtual function to allocate the resources for the ring buffer using the given spec.
| bool Gst::AudioRingBuffer::activate | ( | bool | active | ) |
Activate buf to start or stop pulling data.
MT safe.
- Parameters
-
active The new mode.
- Returns
trueif the device could be activated in the requested mode,falseon error.
|
virtual |
Virtual function to activate the thread that starts pulling and monitoring the consumed segments in the device.
Since 0.10.22.
| void Gst::AudioRingBuffer::advance | ( | guint | advance | ) |
Subclasses should call this function to notify the fact that advance segments are now processed by the device.
MT safe.
- Parameters
-
advance The number of segments written.
| void Gst::AudioRingBuffer::clear | ( | int | segment | ) |
Clear the given segment of the buffer with silence samples.
This function is used by subclasses.
MT safe.
- Parameters
-
segment The segment to clear.
| void Gst::AudioRingBuffer::clear_all | ( | ) |
Fill the ringbuffer with silence.
MT safe.
|
virtual |
Virtual function to clear the entire audioringbuffer Since 0.10.24.
| bool Gst::AudioRingBuffer::close_device | ( | ) |
Close the audio device associated with the ring buffer.
The ring buffer should already have been released via release().
- Returns
trueif the device could be closed,falseon error.
MT safe.
|
virtual |
Virtual function to close the device.
| guint Gst::AudioRingBuffer::commit | ( | guint64 & | sample, |
| const std::vector< guint8 > & | data, | ||
| int | in_samples, | ||
| int | out_samples, | ||
| int & | accum | ||
| ) |
Commit in_samples samples pointed to by data to the ringbuffer buf.
in_samples and out_samples define the rate conversion to perform on the samples in data. For negative rates, out_samples must be negative and in_samples positive.
When out_samples is positive, the first sample will be written at position sample in the ringbuffer. When out_samples is negative, the last sample will be written to sample in reverse order.
out_samples does not need to be a multiple of the segment size of the ringbuffer although it is recommended for optimal performance.
accum will hold a temporary accumulator used in rate conversion and should be set to 0 when this function is first called. In case the commit operation is interrupted, one can resume the processing by passing the previously returned accum value back to this function.
MT safe.
- Parameters
-
sample The sample position of the data. data The data to commit. in_samples The number of samples in the data to commit. out_samples The number of samples to write to the ringbuffer. accum Accumulator for rate conversion.
- Returns
- The number of samples written to the ringbuffer or -1 on error. The number of samples written can be less than out_samples when buf was interrupted with a flush or stop.
|
virtual |
Virtual function to write samples into the ring buffer.
| bool Gst::AudioRingBuffer::convert | ( | Gst::Format | src_fmt, |
| gint64 | src_val, | ||
| Gst::Format | dest_fmt, | ||
| gint64 & | dest_val | ||
| ) | const |
Convert src_val in src_fmt to the equivalent value in dest_fmt.
The result will be put in dest_val.
- Parameters
-
src_fmt The source format. src_val The source value. dest_fmt The destination format. dest_val A location to store the converted value.
- Returns
trueif the conversion succeeded.
|
virtual |
Virtual function to get number of samples queued in device.
| bool Gst::AudioRingBuffer::device_is_open | ( | ) | const |
Checks the status of the device associated with the ring buffer.
- Returns
trueif the device was open,falseif it was closed.
MT safe.
| guint Gst::AudioRingBuffer::get_delay | ( | ) | const |
Get the number of samples queued in the audio device.
This is usually less than the segment size but can be bigger when the implementation uses another internal buffer between the audio device.
For playback ringbuffers this is the amount of samples transfered from the ringbuffer to the device but still not played.
For capture ringbuffers this is the amount of samples in the device that are not yet transfered to the ringbuffer.
- Returns
- The number of samples queued in the audio device.
MT safe.
| guint64 Gst::AudioRingBuffer::get_samples_done | ( | ) | const |
Get the number of samples that were processed by the ringbuffer since it was last started.
This does not include the number of samples not yet processed (see delay()).
- Returns
- The number of samples processed by the ringbuffer.
MT safe.
|
static |
Get the GType for this class, for use with the underlying GObject type system.
|
inline |
Provides access to the underlying C GObject.
|
inline |
Provides access to the underlying C GObject.
| GstAudioRingBuffer* Gst::AudioRingBuffer::gobj_copy | ( | ) |
Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs.
| bool Gst::AudioRingBuffer::is_acquired | ( | ) | const |
Check if the ringbuffer is acquired and ready to use.
- Returns
trueif the ringbuffer is acquired,falseon error.
MT safe.
| bool Gst::AudioRingBuffer::is_active | ( | ) | const |
| gboolean Gst::AudioRingBuffer::is_flushing | ( | ) |
| bool Gst::AudioRingBuffer::open_device | ( | ) |
Open the audio device associated with the ring buffer.
Does not perform any setup on the device. You must open the device before acquiring the ring buffer.
- Returns
trueif the device could be opened,falseon error.
MT safe.
|
virtual |
Virtual function to open the device.
Don't set any params or allocate anything.
|
static |
| bool Gst::AudioRingBuffer::pause | ( | ) |
Pause processing samples from the ringbuffer.
- Returns
trueif the device could be paused,falseon error.
MT safe.
|
virtual |
Virtual function to pause processing of samples.
| bool Gst::AudioRingBuffer::prepare_read | ( | int & | segment, |
| std::vector< guint8 > & | readptr, | ||
| int & | len | ||
| ) |
Returns a pointer to memory where the data from segment segment can be found.
This function is mostly used by subclasses.
- Parameters
-
segment The segment to read. readptr The pointer to the memory where samples can be read. len The number of bytes to read.
- Returns
falseif the buffer is not started.
MT safe.
| guint Gst::AudioRingBuffer::read | ( | guint64 | sample, |
| const std::vector< guint8 > & | data, | ||
| guint | len, | ||
| ClockTime& | timestamp | ||
| ) |
Read len samples from the ringbuffer into the memory pointed to by data.
The first sample should be read from position sample in the ringbuffer.
len should not be a multiple of the segment size of the ringbuffer although it is recommended.
timestamp will return the timestamp associated with the data returned.
- Parameters
-
sample The sample position of the data. data Where the data should be read. len The number of samples in data to read. timestamp Where the timestamp is returned.
- Returns
- The number of samples read from the ringbuffer or -1 on error.
MT safe.
| bool Gst::AudioRingBuffer::release | ( | ) |
Free the resources of the ringbuffer.
- Returns
trueif the device could be released,falseon error.
MT safe.
|
virtual |
Virtual function to free resources of the ring buffer.
|
virtual |
Virtual function to resume processing of samples after pause.
| void Gst::AudioRingBuffer::set_channel_position | ( | const Gst::AudioChannelPosition& | position | ) |
Tell the ringbuffer about the device's channel positions.
This must be called in when the ringbuffer is acquired.
- Parameters
-
position The device channel positions.
| void Gst::AudioRingBuffer::set_fill_slot | ( | const SlotFill& | slot | ) |
Sets the given fill slot on the buffer.
The slot will be called every time a segment has been written to a device.
MT safe.
- Parameters
-
slot The fill slot to set.
| void Gst::AudioRingBuffer::set_flushing | ( | bool | flushing | ) |
Set the ringbuffer to flushing mode or normal mode.
MT safe.
- Parameters
-
flushing The new mode.
| void Gst::AudioRingBuffer::set_may_start | ( | bool | allowed | ) |
Tell the ringbuffer that it is allowed to start playback when the ringbuffer is filled with samples.
MT safe.
- Parameters
-
allowed The new value.
| void Gst::AudioRingBuffer::set_sample | ( | guint64 | sample | ) |
Make sure that the next sample written to the device is accounted for as being the sample sample written to the device.
This value will be used in reporting the current sample position of the ringbuffer.
This function will also clear the buffer with silence.
MT safe.
- Parameters
-
sample The sample number to set.
| void Gst::AudioRingBuffer::set_timestamp | ( | gint | readseg, |
| ClockTime | timestamp | ||
| ) |
| bool Gst::AudioRingBuffer::start | ( | ) |
Start processing samples from the ringbuffer.
- Returns
trueif the device could be started,falseon error.
MT safe.
|
virtual |
Virtual function to start processing of samples.
| bool Gst::AudioRingBuffer::stop | ( | ) |
Stop processing samples from the ringbuffer.
- Returns
trueif the device could be stopped,falseon error.
MT safe.
|
virtual |
Virtual function to stop processing of samples.
Friends And Related Function Documentation
|
related |
A Glib::wrap() method for this object.
- Parameters
-
object The C instance. take_copy False if the result should take ownership of the C instance. True if it should take a new copy or ref.
- Returns
- A C++ instance that wraps this C instance.
The documentation for this class was generated from the following file:
- gstreamermm/audioringbuffer.h

Public Member Functions inherited from