gstringbuffer

gstringbuffer — Base class for audio ringbuffer implementations

Synopsis


#include <gst/audio/gstringbuffer.h>


            GstRingBuffer;
            GstRingBufferClass;
            GstRingBufferSpec;
void        (*GstRingBufferCallback)        (GstRingBuffer *rbuf,
                                             guint8 *data,
                                             guint len,
                                             gpointer user_data);
enum        GstRingBufferSegState;
enum        GstRingBufferState;
enum        GstBufferFormat;
enum        GstBufferFormatType;
#define     GST_RING_BUFFER_BROADCAST       (buf)
#define     GST_RING_BUFFER_GET_COND        (buf)
#define     GST_RING_BUFFER_SIGNAL          (buf)
#define     GST_RING_BUFFER_WAIT            (buf)
void        gst_ring_buffer_set_callback    (GstRingBuffer *buf,
                                             GstRingBufferCallback cb,
                                             gpointer user_data);
gboolean    gst_ring_buffer_acquire         (GstRingBuffer *buf,
                                             GstRingBufferSpec *spec);
gboolean    gst_ring_buffer_release         (GstRingBuffer *buf);
gboolean    gst_ring_buffer_is_acquired     (GstRingBuffer *buf);
gboolean    gst_ring_buffer_start           (GstRingBuffer *buf);
gboolean    gst_ring_buffer_pause           (GstRingBuffer *buf);
gboolean    gst_ring_buffer_stop            (GstRingBuffer *buf);
guint       gst_ring_buffer_delay           (GstRingBuffer *buf);
guint64     gst_ring_buffer_samples_done    (GstRingBuffer *buf);
void        gst_ring_buffer_set_sample      (GstRingBuffer *buf,
                                             guint64 sample);
guint       gst_ring_buffer_commit          (GstRingBuffer *buf,
                                             guint64 sample,
                                             guchar *data,
                                             guint len);
guint       gst_ring_buffer_commit_full     (GstRingBuffer *buf,
                                             guint64 *sample,
                                             guchar *data,
                                             gint in_samples,
                                             gint out_samples,
                                             gint *accum);
gboolean    gst_ring_buffer_prepare_read    (GstRingBuffer *buf,
                                             gint *segment,
                                             guint8 **readptr,
                                             gint *len);
guint       gst_ring_buffer_read            (GstRingBuffer *buf,
                                             guint64 sample,
                                             guchar *data,
                                             guint len);
void        gst_ring_buffer_clear           (GstRingBuffer *buf,
                                             gint segment);
void        gst_ring_buffer_clear_all       (GstRingBuffer *buf);
void        gst_ring_buffer_advance         (GstRingBuffer *buf,
                                             guint advance);
gboolean    gst_ring_buffer_close_device    (GstRingBuffer *buf);
gboolean    gst_ring_buffer_open_device     (GstRingBuffer *buf);
gboolean    gst_ring_buffer_device_is_open  (GstRingBuffer *buf);
void        gst_ring_buffer_may_start       (GstRingBuffer *buf,
                                             gboolean allowed);
gboolean    gst_ring_buffer_parse_caps      (GstRingBufferSpec *spec,
                                             GstCaps *caps);
void        gst_ring_buffer_set_flushing    (GstRingBuffer *buf,
                                             gboolean flushing);


Object Hierarchy


  GObject
   +----GstObject
         +----GstRingBuffer

Description

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.

Last reviewed on 2006-02-02 (0.10.4)

Details

GstRingBuffer

typedef struct {
  GCond                 *cond;
  gboolean               open;
  gboolean               acquired;
  GstBuffer             *data;
  GstRingBufferSpec      spec;
  GstRingBufferSegState *segstate;
  gint                   samples_per_seg;
  guint8                *empty_seg;

  gint                   state;
  gint                   segdone;
  gint                   segbase;
  gint                   waiting;
} GstRingBuffer;

The ringbuffer base class structure.

GCond *cond;GCondcond used to signal start/stop/pause/resume actions used to signal start/stop/pause/resume actions gboolean open;gbooleanopen boolean indicating that the ringbuffer is open boolean indicating that the ringbuffer is open gboolean acquired;gbooleanacquired boolean indicating that the ringbuffer is acquired boolean indicating that the ringbuffer is acquired GstBuffer *data;GstBufferdata data in the ringbuffer data in the ringbuffer GstRingBufferSpec spec;GstRingBufferSpecspec format and layout of the ringbuffer data format and layout of the ringbuffer data GstRingBufferSegState *segstate;GstRingBufferSegStatesegstate status of each segment in the ringbuffer (unused) status of each segment in the ringbuffer (unused) gint samples_per_seg;gintsamples_per_seg number of samples in one segment number of samples in one segment guint8 *empty_seg;guint8empty_seg pointer to memory holding one segment of silence samples pointer to memory holding one segment of silence samples gint state;gintstate state of the buffer state of the buffer gint segdone;gintsegdone readpointer in the ringbuffer readpointer in the ringbuffer gint segbase;gintsegbase segment corresponding to segment 0 (unused) segment corresponding to segment 0 (unused) gint waiting;gintwaiting is a reader or writer waiting for a free segment is a reader or writer waiting for a free segment
GCond *cond; used to signal start/stop/pause/resume actions
gboolean open; boolean indicating that the ringbuffer is open
gboolean acquired; boolean indicating that the ringbuffer is acquired
GstBuffer *data; data in the ringbuffer
GstRingBufferSpec spec; format and layout of the ringbuffer data
GstRingBufferSegState *segstate; status of each segment in the ringbuffer (unused)
gint samples_per_seg; number of samples in one segment
guint8 *empty_seg; pointer to memory holding one segment of silence samples
gint state; state of the buffer
gint segdone; readpointer in the ringbuffer
gint segbase; segment corresponding to segment 0 (unused)
gint waiting; is a reader or writer waiting for a free segment

GstRingBufferClass

typedef struct {
  GstObjectClass parent_class;

  gboolean     (*open_device)  (GstRingBuffer *buf);
  gboolean     (*acquire)      (GstRingBuffer *buf, GstRingBufferSpec *spec);
  gboolean     (*release)      (GstRingBuffer *buf);
  gboolean     (*close_device) (GstRingBuffer *buf);

  gboolean     (*start)        (GstRingBuffer *buf);
  gboolean     (*pause)        (GstRingBuffer *buf);
  gboolean     (*resume)       (GstRingBuffer *buf);
  gboolean     (*stop)         (GstRingBuffer *buf);

  guint        (*delay)        (GstRingBuffer *buf);
} GstRingBufferClass;

The vmethods that subclasses can override to implement the ringbuffer.

GstObjectClass parent_class;GstObjectClassparent_class open_device ()open_device open the device, don't set any params or allocate anything open the device, don't set any params or allocate anything acquire ()acquire allocate the resources for the ringbuffer using the given spec allocate the resources for the ringbuffer using the given spec release ()release free resources of the ringbuffer free resources of the ringbuffer close_device ()close_device close the device close the device start ()start start processing of samples start processing of samples pause ()pause pause processing of samples pause processing of samples resume ()resume resume processing of samples after pause resume processing of samples after pause stop ()stop stop processing of samples stop processing of samples delay ()delay get number of samples queued in device get number of samples queued in device
GstObjectClass parent_class;
open_device () open the device, don't set any params or allocate anything
acquire () allocate the resources for the ringbuffer using the given spec
release () free resources of the ringbuffer
close_device () close the device
start () start processing of samples
pause () pause processing of samples
resume () resume processing of samples after pause
stop () stop processing of samples
delay () get number of samples queued in device

GstRingBufferSpec

typedef struct {
  /* in */
  GstCaps  *caps;               /* the caps of the buffer */

  /* in/out */
  GstBufferFormatType   type;
  GstBufferFormat format;
  gboolean  sign;
  gboolean  bigend;
  gint      width;
  gint      depth;
  gint      rate;
  gint      channels;
  
  guint64  latency_time;        /* the required/actual latency time */
  guint64  buffer_time;         /* the required/actual time of the buffer */
  gint     segsize;             /* size of one buffer segement */
  gint     segtotal;            /* total number of segments */

  /* out */
  gint     bytes_per_sample;    /* number of bytes of one sample */
  guint8   silence_sample[32];  /* bytes representing silence */
} GstRingBufferSpec;

The structure containing the format specification of the ringbuffer.

GstCaps *caps;GstCapscaps The caps that generated the Spec. The caps that generated the Spec. GstBufferFormatType type;GstBufferFormatTypetype the sample type the sample type GstBufferFormat format;GstBufferFormatformat the sample format the sample format gboolean sign;gbooleansign the sample sign the sample sign gboolean bigend;gbooleanbigend the endianness of the samples the endianness of the samples gint width;gintwidth the width of the samples the width of the samples gint depth;gintdepth th depth of the samples th depth of the samples gint rate;gintrate the samplerate the samplerate gint channels;gintchannels the number of channels the number of channels guint64 latency_time;guint64latency_time the latency in microseconds the latency in microseconds guint64 buffer_time;guint64buffer_time the total buffer size in microseconds the total buffer size in microseconds gint segsize;gintsegsize the size of one segment in bytes the size of one segment in bytes gint segtotal;gintsegtotal the total number of segments the total number of segments gint bytes_per_sample;gintbytes_per_sample number of bytes in one sample number of bytes in one sample guint8 silence_sample[32];guint8silence_sample bytes representing one sample of silence bytes representing one sample of silence
GstCaps *caps; The caps that generated the Spec.
GstBufferFormatType type; the sample type
GstBufferFormat format; the sample format
gboolean sign; the sample sign
gboolean bigend; the endianness of the samples
gint width; the width of the samples
gint depth; th depth of the samples
gint rate; the samplerate
gint channels; the number of channels
guint64 latency_time; the latency in microseconds
guint64 buffer_time; the total buffer size in microseconds
gint segsize; the size of one segment in bytes
gint segtotal; the total number of segments
gint bytes_per_sample; number of bytes in one sample
guint8 silence_sample[32]; bytes representing one sample of silence

GstRingBufferCallback ()

void        (*GstRingBufferCallback)        (GstRingBuffer *rbuf,
                                             guint8 *data,
                                             guint len,
                                             gpointer user_data);

This function is set with gst_ring_buffer_set_callback() and is called to fill the memory at data with len bytes of samples.

rbuf :rbuf a GstRingBuffer a GstRingBuffer GstRingBufferGstRingBufferdata :data target to fill target to fill len :len amount to fill amount to fill user_data :user_data user data user data
rbuf : a GstRingBuffer
data : target to fill
len : amount to fill
user_data : user data

enum GstRingBufferSegState

typedef enum {
  GST_SEGSTATE_INVALID,
  GST_SEGSTATE_EMPTY,
  GST_SEGSTATE_FILLED,
  GST_SEGSTATE_PARTIAL,
} GstRingBufferSegState;

The state of a segment in the ringbuffer.

GST_SEGSTATE_INVALIDGST_SEGSTATE_INVALID The content of the segment is invalid The content of the segment is invalid GST_SEGSTATE_EMPTYGST_SEGSTATE_EMPTY The segment is empty The segment is empty GST_SEGSTATE_FILLEDGST_SEGSTATE_FILLED The segment contains valid data The segment contains valid data GST_SEGSTATE_PARTIALGST_SEGSTATE_PARTIAL The segment partially contains valid data The segment partially contains valid data
GST_SEGSTATE_INVALID The content of the segment is invalid
GST_SEGSTATE_EMPTY The segment is empty
GST_SEGSTATE_FILLED The segment contains valid data
GST_SEGSTATE_PARTIAL The segment partially contains valid data

enum GstRingBufferState

typedef enum {
  GST_RING_BUFFER_STATE_STOPPED,
  GST_RING_BUFFER_STATE_PAUSED,
  GST_RING_BUFFER_STATE_STARTED,
} GstRingBufferState;

The state of the ringbuffer.

GST_RING_BUFFER_STATE_STOPPEDGST_RING_BUFFER_STATE_STOPPED The ringbuffer is stopped The ringbuffer is stopped GST_RING_BUFFER_STATE_PAUSEDGST_RING_BUFFER_STATE_PAUSED The ringbuffer is paused The ringbuffer is paused GST_RING_BUFFER_STATE_STARTEDGST_RING_BUFFER_STATE_STARTED The ringbuffer is started The ringbuffer is started
GST_RING_BUFFER_STATE_STOPPED The ringbuffer is stopped
GST_RING_BUFFER_STATE_PAUSED The ringbuffer is paused
GST_RING_BUFFER_STATE_STARTED The ringbuffer is started

enum GstBufferFormat

typedef enum
{
  GST_UNKNOWN,

  GST_S8,
  GST_U8,

  GST_S16_LE,
  GST_S16_BE,
  GST_U16_LE,
  GST_U16_BE,

  GST_S24_LE,
  GST_S24_BE,
  GST_U24_LE,
  GST_U24_BE,

  GST_S32_LE,
  GST_S32_BE,
  GST_U32_LE,
  GST_U32_BE,

  GST_S24_3LE,
  GST_S24_3BE,
  GST_U24_3LE,
  GST_U24_3BE,
  GST_S20_3LE,
  GST_S20_3BE,
  GST_U20_3LE,
  GST_U20_3BE,
  GST_S18_3LE,
  GST_S18_3BE,
  GST_U18_3LE,
  GST_U18_3BE,

  GST_FLOAT32_LE,
  GST_FLOAT32_BE,

  GST_FLOAT64_LE,
  GST_FLOAT64_BE,

  GST_MU_LAW,
  GST_A_LAW,
  GST_IMA_ADPCM,
  GST_MPEG,
  GST_GSM,

  /* fill me */

} GstBufferFormat;


enum GstBufferFormatType

typedef enum
{
  GST_BUFTYPE_LINEAR,
  GST_BUFTYPE_FLOAT,
  GST_BUFTYPE_MU_LAW,
  GST_BUFTYPE_A_LAW,
  GST_BUFTYPE_IMA_ADPCM,
  GST_BUFTYPE_MPEG,
  GST_BUFTYPE_GSM,
} GstBufferFormatType;

The format of the samples in the ringbuffer.

GST_BUFTYPE_LINEARGST_BUFTYPE_LINEAR samples in linear PCM samples in linear PCM GST_BUFTYPE_FLOATGST_BUFTYPE_FLOAT samples in float samples in float GST_BUFTYPE_MU_LAWGST_BUFTYPE_MU_LAW samples in mulaw samples in mulaw GST_BUFTYPE_A_LAWGST_BUFTYPE_A_LAW samples in alaw samples in alaw GST_BUFTYPE_IMA_ADPCMGST_BUFTYPE_IMA_ADPCM samples in ima adpcm samples in ima adpcm GST_BUFTYPE_MPEGGST_BUFTYPE_MPEG samples in mpeg audio format samples in mpeg audio format GST_BUFTYPE_GSMGST_BUFTYPE_GSM samples in gsm format samples in gsm format
GST_BUFTYPE_LINEAR samples in linear PCM
GST_BUFTYPE_FLOAT samples in float
GST_BUFTYPE_MU_LAW samples in mulaw
GST_BUFTYPE_A_LAW samples in alaw
GST_BUFTYPE_IMA_ADPCM samples in ima adpcm
GST_BUFTYPE_MPEG samples in mpeg audio format
GST_BUFTYPE_GSM samples in gsm format

GST_RING_BUFFER_BROADCAST()

#define GST_RING_BUFFER_BROADCAST(buf)(g_cond_broadcast (GST_RING_BUFFER_GET_COND (buf)))

buf :buf
buf :

GST_RING_BUFFER_GET_COND()

#define GST_RING_BUFFER_GET_COND(buf) (((GstRingBuffer *)buf)->cond)

buf :buf
buf :

GST_RING_BUFFER_SIGNAL()

#define GST_RING_BUFFER_SIGNAL(buf)   (g_cond_signal (GST_RING_BUFFER_GET_COND (buf)))

buf :buf
buf :

GST_RING_BUFFER_WAIT()

#define GST_RING_BUFFER_WAIT(buf)     (g_cond_wait (GST_RING_BUFFER_GET_COND (buf), GST_OBJECT_GET_LOCK (buf)))

buf :buf
buf :

gst_ring_buffer_set_callback ()

void        gst_ring_buffer_set_callback    (GstRingBuffer *buf,
                                             GstRingBufferCallback cb,
                                             gpointer user_data);

Sets the given callback function on the buffer. This function will be called every time a segment has been written to a device.

MT safe.

buf :buf the GstRingBuffer to set the callback on the GstRingBuffer to set the callback on GstRingBufferGstRingBuffercb :cb the callback to set the callback to set user_data :user_data user data passed to the callback user data passed to the callback
buf : the GstRingBuffer to set the callback on
cb : the callback to set
user_data : user data passed to the callback

gst_ring_buffer_acquire ()

gboolean    gst_ring_buffer_acquire         (GstRingBuffer *buf,
                                             GstRingBufferSpec *spec);

Allocate the resources for the ringbuffer. This function fills in the data pointer of the ring buffer with a valid GstBuffer to which samples can be written.

buf :buf the GstRingBuffer to acquire the GstRingBuffer to acquire GstRingBufferGstRingBufferspec :spec the specs of the buffer the specs of the buffer Returns :Returns TRUE if the device could be acquired, FALSE on error. MT safe. TRUE if the device could be acquired, FALSE on error. MT safe.
buf : the GstRingBuffer to acquire
spec : the specs of the buffer
Returns : TRUE if the device could be acquired, FALSE on error. MT safe.

gst_ring_buffer_release ()

gboolean    gst_ring_buffer_release         (GstRingBuffer *buf);

Free the resources of the ringbuffer.

buf :buf the GstRingBuffer to release the GstRingBuffer to release GstRingBufferGstRingBufferReturns :Returns TRUE if the device could be released, FALSE on error. MT safe. TRUE if the device could be released, FALSE on error. MT safe.
buf : the GstRingBuffer to release
Returns : TRUE if the device could be released, FALSE on error. MT safe.

gst_ring_buffer_is_acquired ()

gboolean    gst_ring_buffer_is_acquired     (GstRingBuffer *buf);

Check if the ringbuffer is acquired and ready to use.

buf :buf the GstRingBuffer to check the GstRingBuffer to check GstRingBufferGstRingBufferReturns :Returns TRUE if the ringbuffer is acquired, FALSE on error. MT safe. TRUE if the ringbuffer is acquired, FALSE on error. MT safe.
buf : the GstRingBuffer to check
Returns : TRUE if the ringbuffer is acquired, FALSE on error. MT safe.

gst_ring_buffer_start ()

gboolean    gst_ring_buffer_start           (GstRingBuffer *buf);

Start processing samples from the ringbuffer.

buf :buf the GstRingBuffer to start the GstRingBuffer to start GstRingBufferGstRingBufferReturns :Returns TRUE if the device could be started, FALSE on error. MT safe. TRUE if the device could be started, FALSE on error. MT safe.
buf : the GstRingBuffer to start
Returns : TRUE if the device could be started, FALSE on error. MT safe.

gst_ring_buffer_pause ()

gboolean    gst_ring_buffer_pause           (GstRingBuffer *buf);

Pause processing samples from the ringbuffer.

buf :buf the GstRingBuffer to pause the GstRingBuffer to pause GstRingBufferGstRingBufferReturns :Returns TRUE if the device could be paused, FALSE on error. MT safe. TRUE if the device could be paused, FALSE on error. MT safe.
buf : the GstRingBuffer to pause
Returns : TRUE if the device could be paused, FALSE on error. MT safe.

gst_ring_buffer_stop ()

gboolean    gst_ring_buffer_stop            (GstRingBuffer *buf);

Stop processing samples from the ringbuffer.

buf :buf the GstRingBuffer to stop the GstRingBuffer to stop GstRingBufferGstRingBufferReturns :Returns TRUE if the device could be stopped, FALSE on error. MT safe. TRUE if the device could be stopped, FALSE on error. MT safe.
buf : the GstRingBuffer to stop
Returns : TRUE if the device could be stopped, FALSE on error. MT safe.

gst_ring_buffer_delay ()

guint       gst_ring_buffer_delay           (GstRingBuffer *buf);

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.

buf :buf the GstRingBuffer to query the GstRingBuffer to query GstRingBufferGstRingBufferReturns :Returns The number of samples queued in the audio device. MT safe. The number of samples queued in the audio device. MT safe.
buf : the GstRingBuffer to query
Returns : The number of samples queued in the audio device. MT safe.

gst_ring_buffer_samples_done ()

guint64     gst_ring_buffer_samples_done    (GstRingBuffer *buf);

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 gst_ring_buffer_delay()).

buf :buf the GstRingBuffer to query the GstRingBuffer to query GstRingBufferGstRingBufferReturns :Returns The number of samples processed by the ringbuffer. MT safe. The number of samples processed by the ringbuffer. MT safe.
buf : the GstRingBuffer to query
Returns : The number of samples processed by the ringbuffer. MT safe.

gst_ring_buffer_set_sample ()

void        gst_ring_buffer_set_sample      (GstRingBuffer *buf,
                                             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.

buf :buf the GstRingBuffer to use the GstRingBuffer to use GstRingBufferGstRingBuffersample :sample the sample number to set the sample number to set
buf : the GstRingBuffer to use
sample : the sample number to set

gst_ring_buffer_commit ()

guint       gst_ring_buffer_commit          (GstRingBuffer *buf,
                                             guint64 sample,
                                             guchar *data,
                                             guint len);

Same as gst_ring_buffer_commit_full() but with a num, denom of 1, ignoring accum.

buf :buf the GstRingBuffer to commit the GstRingBuffer to commit GstRingBufferGstRingBuffersample :sample the sample position of the data the sample position of the data data :data the data to commit the data to commit len :len the number of samples in the data to commit the number of samples in the data to commit Returns :Returns The number of samples written to the ringbuffer or -1 on error. MT safe. The number of samples written to the ringbuffer or -1 on error. MT safe.
buf : the GstRingBuffer to commit
sample : the sample position of the data
data : the data to commit
len : the number of samples in the data to commit
Returns : The number of samples written to the ringbuffer or -1 on error. MT safe.

gst_ring_buffer_commit_full ()

guint       gst_ring_buffer_commit_full     (GstRingBuffer *buf,
                                             guint64 *sample,
                                             guchar *data,
                                             gint in_samples,
                                             gint out_samples,
                                             gint *accum);

Commit len samples pointed to by data to the ringbuffer buf.

num and denom define the rate conversion to perform on the the samples in data. For negative rates, num must be negative and denom positive.

When num is positive, the first sample will be written at position sample in the ringbuffer. When num is negative, the last sample will be written to sample in reverse order.

len does not need to be a multiple of the segment size of the ringbuffer (if num and denom are both 1) although it is recommended for optimal performance.

buf :buf the GstRingBuffer to commit the GstRingBuffer to commit GstRingBufferGstRingBuffersample :sample the sample position of the data the sample position of the data data :data the data to commit the data to commit in_samples :in_samples the number of samples in the data to commit the number of samples in the data to commit out_samples :out_samples accum :accum accumulator for rate conversion. accumulator for rate conversion. Returns :Returns The number of samples written to the ringbuffer or -1 on error. The number of samples written can be less than len when buf was interrupted with a flush or stop. The number of samples written to the ringbuffer or -1 on error. The number of samples written can be less than len when buf was interrupted with a flush or stop. lenbuf
buf : the GstRingBuffer to commit
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 :
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 len when buf was interrupted with a flush or stop.

Since 0.10.11. MT safe.


gst_ring_buffer_prepare_read ()

gboolean    gst_ring_buffer_prepare_read    (GstRingBuffer *buf,
                                             gint *segment,
                                             guint8 **readptr,
                                             gint *len);

Returns a pointer to memory where the data from segment segment can be found. This function is mostly used by subclasses.

buf :buf the GstRingBuffer to read from the GstRingBuffer to read from GstRingBufferGstRingBuffersegment :segment the segment to read the segment to read readptr :readptr the pointer to the memory where samples can be read the pointer to the memory where samples can be read len :len the number of bytes to read the number of bytes to read Returns :Returns FALSE if the buffer is not started. MT safe. FALSE if the buffer is not started. MT safe.
buf : the GstRingBuffer to read from
segment : the segment to read
readptr : the pointer to the memory where samples can be read
len : the number of bytes to read
Returns : FALSE if the buffer is not started. MT safe.

gst_ring_buffer_read ()

guint       gst_ring_buffer_read            (GstRingBuffer *buf,
                                             guint64 sample,
                                             guchar *data,
                                             guint len);

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.

buf :buf the GstRingBuffer to read from the GstRingBuffer to read from GstRingBufferGstRingBuffersample :sample the sample position of the data the sample position of the data data :data where the data should be read where the data should be read len :len the number of samples in data to read the number of samples in data to read Returns :Returns The number of samples read from the ringbuffer or -1 on error. MT safe. The number of samples read from the ringbuffer or -1 on error. MT safe.
buf : the GstRingBuffer to read from
sample : the sample position of the data
data : where the data should be read
len : the number of samples in data to read
Returns : The number of samples read from the ringbuffer or -1 on error. MT safe.

gst_ring_buffer_clear ()

void        gst_ring_buffer_clear           (GstRingBuffer *buf,
                                             gint segment);

Clear the given segment of the buffer with silence samples. This function is used by subclasses.

MT safe.

buf :buf the GstRingBuffer to clear the GstRingBuffer to clear GstRingBufferGstRingBuffersegment :segment the segment to clear the segment to clear
buf : the GstRingBuffer to clear
segment : the segment to clear

gst_ring_buffer_clear_all ()

void        gst_ring_buffer_clear_all       (GstRingBuffer *buf);

Fill the ringbuffer with silence.

MT safe.

buf :buf the GstRingBuffer to clear the GstRingBuffer to clear GstRingBufferGstRingBuffer
buf : the GstRingBuffer to clear

gst_ring_buffer_advance ()

void        gst_ring_buffer_advance         (GstRingBuffer *buf,
                                             guint advance);

Subclasses should call this function to notify the fact that advance segments are now processed by the device.

MT safe.

buf :buf the GstRingBuffer to advance the GstRingBuffer to advance GstRingBufferGstRingBufferadvance :advance the number of segments written the number of segments written
buf : the GstRingBuffer to advance
advance : the number of segments written

gst_ring_buffer_close_device ()

gboolean    gst_ring_buffer_close_device    (GstRingBuffer *buf);

Close the audio device associated with the ring buffer. The ring buffer should already have been released via gst_ring_buffer_release().

buf :buf the GstRingBuffer the GstRingBuffer GstRingBufferGstRingBufferReturns :Returns TRUE if the device could be closed, FALSE on error. MT safe. TRUE if the device could be closed, FALSE on error. MT safe.
buf : the GstRingBuffer
Returns : TRUE if the device could be closed, FALSE on error. MT safe.

gst_ring_buffer_open_device ()

gboolean    gst_ring_buffer_open_device     (GstRingBuffer *buf);

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.

buf :buf the GstRingBuffer the GstRingBuffer GstRingBufferGstRingBufferReturns :Returns TRUE if the device could be opened, FALSE on error. MT safe. TRUE if the device could be opened, FALSE on error. MT safe.
buf : the GstRingBuffer
Returns : TRUE if the device could be opened, FALSE on error. MT safe.

gst_ring_buffer_device_is_open ()

gboolean    gst_ring_buffer_device_is_open  (GstRingBuffer *buf);

Checks the status of the device associated with the ring buffer.

buf :buf the GstRingBuffer the GstRingBuffer GstRingBufferGstRingBufferReturns :Returns TRUE if the device was open, FALSE if it was closed. MT safe. TRUE if the device was open, FALSE if it was closed. MT safe.
buf : the GstRingBuffer
Returns : TRUE if the device was open, FALSE if it was closed. MT safe.

gst_ring_buffer_may_start ()

void        gst_ring_buffer_may_start       (GstRingBuffer *buf,
                                             gboolean allowed);

Tell the ringbuffer that it is allowed to start playback when the ringbuffer is filled with samples.

buf :buf the GstRingBuffer the GstRingBuffer GstRingBufferGstRingBufferallowed :allowed the new value the new value
buf : the GstRingBuffer
allowed : the new value

Since 0.10.6 MT safe.


gst_ring_buffer_parse_caps ()

gboolean    gst_ring_buffer_parse_caps      (GstRingBufferSpec *spec,
                                             GstCaps *caps);

Parse caps into spec.

spec :spec a spec a spec caps :caps a GstCaps a GstCaps GstCapsGstCapsReturns :Returns TRUE if the caps could be parsed. TRUE if the caps could be parsed.
spec : a spec
caps : a GstCaps
Returns : TRUE if the caps could be parsed.

gst_ring_buffer_set_flushing ()

void        gst_ring_buffer_set_flushing    (GstRingBuffer *buf,
                                             gboolean flushing);

Set the ringbuffer to flushing mode or normal mode.

MT safe.

buf :buf the GstRingBuffer to flush the GstRingBuffer to flush GstRingBufferGstRingBufferflushing :flushing the new mode the new mode
buf : the GstRingBuffer to flush
flushing : the new mode

See Also

gstbaseaudiosink