XMMS2
Typedefs | Functions
Ringbuffer

Ringbuffer primitive. More...

Typedefs

typedef struct xmms_ringbuf_hotspot_St xmms_ringbuf_hotspot_t
 

Functions

guint xmms_ringbuf_size (xmms_ringbuf_t *ringbuf)
 The usable size of the ringbuffer. More...
 
xmms_ringbuf_txmms_ringbuf_new (guint size)
 Allocate a new ringbuffer. More...
 
void xmms_ringbuf_destroy (xmms_ringbuf_t *ringbuf)
 Free all memory used by the ringbuffer. More...
 
void xmms_ringbuf_clear (xmms_ringbuf_t *ringbuf)
 Clear the ringbuffers data. More...
 
guint xmms_ringbuf_bytes_free (const xmms_ringbuf_t *ringbuf)
 Number of bytes free in the ringbuffer. More...
 
guint xmms_ringbuf_bytes_used (const xmms_ringbuf_t *ringbuf)
 Number of bytes used in the buffer. More...
 
guint xmms_ringbuf_read (xmms_ringbuf_t *ringbuf, gpointer data, guint len)
 Reads data from the ringbuffer. More...
 
guint xmms_ringbuf_peek (xmms_ringbuf_t *ringbuf, gpointer data, guint len)
 Same as xmms_ringbuf_read but does not advance in the buffer after the data has been read. More...
 
guint xmms_ringbuf_read_wait (xmms_ringbuf_t *ringbuf, gpointer data, guint len, GMutex *mtx)
 Same as xmms_ringbuf_read but blocks until you have all the data you want. More...
 
guint xmms_ringbuf_peek_wait (xmms_ringbuf_t *ringbuf, gpointer data, guint len, GMutex *mtx)
 Same as xmms_ringbuf_peek but blocks until you have all the data you want. More...
 
guint xmms_ringbuf_write (xmms_ringbuf_t *ringbuf, gconstpointer data, guint len)
 Write data to the ringbuffer. More...
 
guint xmms_ringbuf_write_wait (xmms_ringbuf_t *ringbuf, gconstpointer data, guint len, GMutex *mtx)
 Same as xmms_ringbuf_write but blocks until there is enough free space. More...
 
void xmms_ringbuf_wait_free (const xmms_ringbuf_t *ringbuf, guint len, GMutex *mtx)
 Block until we have free space in the ringbuffer. More...
 
void xmms_ringbuf_wait_used (const xmms_ringbuf_t *ringbuf, guint len, GMutex *mtx)
 Block until we have used space in the buffer. More...
 
gboolean xmms_ringbuf_iseos (const xmms_ringbuf_t *ringbuf)
 Tell if the ringbuffer is EOS. More...
 
void xmms_ringbuf_set_eos (xmms_ringbuf_t *ringbuf, gboolean eos)
 Set EOS flag on ringbuffer. More...
 
void xmms_ringbuf_wait_eos (const xmms_ringbuf_t *ringbuf, GMutex *mtx)
 Block until we are EOSed. More...
 

Detailed Description

Ringbuffer primitive.

Typedef Documentation

◆ xmms_ringbuf_hotspot_t

typedef struct xmms_ringbuf_hotspot_St xmms_ringbuf_hotspot_t

Function Documentation

◆ xmms_ringbuf_bytes_free()

guint xmms_ringbuf_bytes_free ( const xmms_ringbuf_t ringbuf)

Number of bytes free in the ringbuffer.

Definition at line 142 of file ringbuf.c.

Referenced by xmms_ringbuf_wait_free(), and xmms_ringbuf_write().

◆ xmms_ringbuf_bytes_used()

guint xmms_ringbuf_bytes_used ( const xmms_ringbuf_t ringbuf)

Number of bytes used in the buffer.

Definition at line 154 of file ringbuf.c.

Referenced by xmms_output_bytes_available(), xmms_output_latency(), xmms_ringbuf_bytes_free(), xmms_ringbuf_iseos(), and xmms_ringbuf_wait_used().

◆ xmms_ringbuf_clear()

void xmms_ringbuf_clear ( xmms_ringbuf_t ringbuf)

Clear the ringbuffers data.

Definition at line 121 of file ringbuf.c.

◆ xmms_ringbuf_destroy()

void xmms_ringbuf_destroy ( xmms_ringbuf_t ringbuf)

Free all memory used by the ringbuffer.

Definition at line 104 of file ringbuf.c.

◆ xmms_ringbuf_iseos()

gboolean xmms_ringbuf_iseos ( const xmms_ringbuf_t ringbuf)

Tell if the ringbuffer is EOS.

Returns
TRUE if the ringbuffer is EOSed.

Definition at line 416 of file ringbuf.c.

Referenced by xmms_ringbuf_wait_eos().

◆ xmms_ringbuf_new()

xmms_ringbuf_t* xmms_ringbuf_new ( guint  size)

Allocate a new ringbuffer.

Parameters
sizeThe total size of the new ringbuffer
Returns
a new xmms_ringbuf_t

Definition at line 74 of file ringbuf.c.

◆ xmms_ringbuf_peek()

guint xmms_ringbuf_peek ( xmms_ringbuf_t ringbuf,
gpointer  data,
guint  len 
)

Same as xmms_ringbuf_read but does not advance in the buffer after the data has been read.

See also
xmms_ringbuf_read

Definition at line 249 of file ringbuf.c.

Referenced by xmms_ringbuf_peek_wait().

◆ xmms_ringbuf_peek_wait()

guint xmms_ringbuf_peek_wait ( xmms_ringbuf_t ringbuf,
gpointer  data,
guint  len,
GMutex *  mtx 
)

Same as xmms_ringbuf_peek but blocks until you have all the data you want.

See also
xmms_ringbuf_peek

Definition at line 295 of file ringbuf.c.

◆ xmms_ringbuf_read()

guint xmms_ringbuf_read ( xmms_ringbuf_t ringbuf,
gpointer  data,
guint  len 
)

Reads data from the ringbuffer.

This is a non-blocking call and can return less data than you wanted. Use xmms_ringbuf_wait_used to ensure that you get as much data as you want.

Parameters
ringbufBuffer to read from
dataAllocated buffer where the readed data will end up
lennumber of bytes to read
Returns
number of bytes that acutally was read.

Definition at line 222 of file ringbuf.c.

Referenced by xmms_ringbuf_read_wait().

◆ xmms_ringbuf_read_wait()

guint xmms_ringbuf_read_wait ( xmms_ringbuf_t ringbuf,
gpointer  data,
guint  len,
GMutex *  mtx 
)

Same as xmms_ringbuf_read but blocks until you have all the data you want.

See also
xmms_ringbuf_read

Definition at line 265 of file ringbuf.c.

◆ xmms_ringbuf_set_eos()

void xmms_ringbuf_set_eos ( xmms_ringbuf_t ringbuf,
gboolean  eos 
)

Set EOS flag on ringbuffer.

Definition at line 427 of file ringbuf.c.

◆ xmms_ringbuf_size()

guint xmms_ringbuf_size ( xmms_ringbuf_t ringbuf)

The usable size of the ringbuffer.

Definition at line 60 of file ringbuf.c.

◆ xmms_ringbuf_wait_eos()

void xmms_ringbuf_wait_eos ( const xmms_ringbuf_t ringbuf,
GMutex *  mtx 
)

Block until we are EOSed.

Definition at line 445 of file ringbuf.c.

◆ xmms_ringbuf_wait_free()

void xmms_ringbuf_wait_free ( const xmms_ringbuf_t ringbuf,
guint  len,
GMutex *  mtx 
)

Block until we have free space in the ringbuffer.

Definition at line 380 of file ringbuf.c.

◆ xmms_ringbuf_wait_used()

void xmms_ringbuf_wait_used ( const xmms_ringbuf_t ringbuf,
guint  len,
GMutex *  mtx 
)

Block until we have used space in the buffer.

Definition at line 397 of file ringbuf.c.

Referenced by xmms_ringbuf_peek_wait().

◆ xmms_ringbuf_write()

guint xmms_ringbuf_write ( xmms_ringbuf_t ringbuf,
gconstpointer  data,
guint  len 
)

Write data to the ringbuffer.

If not all data can be written to the buffer the function will not block.

See also
xmms_ringbuf_write_wait
Parameters
ringbufRingbuffer to put data in.
dataData to put in ringbuffer
lenLength of data
Returns
Number of bytes that was written

Definition at line 321 of file ringbuf.c.

Referenced by xmms_ringbuf_write_wait().

◆ xmms_ringbuf_write_wait()

guint xmms_ringbuf_write_wait ( xmms_ringbuf_t ringbuf,
gconstpointer  data,
guint  len,
GMutex *  mtx 
)

Same as xmms_ringbuf_write but blocks until there is enough free space.

Definition at line 353 of file ringbuf.c.