- -( dyne // software :: culture :: events :: tazebao :: discussion :: museum \\ freaknet )- -
 
Main Page | Modules | Class Hierarchy | Class List | File List | Class Members | File Members

Pipe Class Reference

#include <pipe.h>

Collaboration diagram for Pipe:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 Pipe (int size=16384)
 Pipe constructor class.

 ~Pipe ()
 Pipe destructor class.

bool set_input_type (char *name)
 set the input conversion type for this Pipe

bool set_output_type (char *name)
 set the output conversion type for this Pipe

void set_block (bool input, bool output)
 set the blocking policy on the read and write

void set_block_timeout (int input, int output)
 set the timeout in milliseconds for the read and write block

int read (int length, void *data)
 read from the pipe

int write (int length, void *data)
 < read from the pipe into a bidimensional float array Mix audio from FIFO pipe into a mixing buffer write into FIFO pipe

void block (bool val)
 Setup blocking behaviour of the Pipe.

int size ()
 tell the amount of data contained in the Pipe

int space ()
 tell the amount of free space in the Pipe

void flush ()
 flush all data contained in the Pipe, loosing it

void flush (int size)
 flush a certain amount of bytes from FIFO Pipe


Public Attributes

bool blocking

Constructor & Destructor Documentation

Pipe::Pipe int  size = 16384  ) 
 

Pipe constructor class.

The constructor initializes all buffers needed, which will be in fact the size of the buffer

Definition at line 127 of file pipe.cpp.

Pipe::~Pipe  ) 
 

Pipe destructor class.

Definition at line 151 of file pipe.cpp.


Member Function Documentation

void Pipe::block bool  val  ) 
 

Setup blocking behaviour of the Pipe.

The term 'blocking' here is used in a quite improper way, read more about in the description of the Pipe class.

void Pipe::flush int  size  ) 
 

flush a certain amount of bytes from FIFO Pipe

Definition at line 371 of file pipe.cpp.

void Pipe::flush  ) 
 

flush all data contained in the Pipe, loosing it

Definition at line 364 of file pipe.cpp.

int Pipe::read int  length,
void *  data
 

read from the pipe

Reads out audio data from the pipe filling up the given buffer which has to be properly allocated.

If the pipe is set 'blocking' then will return -1 if the pipe buffer is full. Otherwise, when non-blocking, will return the amount of data that could be pushed in the pipe.

Parameters:
length amount of data to be read in bytes
data buffer pointer where to read data, must be allocated allready
Returns:
amount of data read, or -1 on error, if Pipe::blocking is true

Definition at line 173 of file pipe.cpp.

void Pipe::set_block bool  input,
bool  output
 

set the blocking policy on the read and write

Definition at line 159 of file pipe.cpp.

void Pipe::set_block_timeout int  input,
int  output
 

set the timeout in milliseconds for the read and write block

Definition at line 166 of file pipe.cpp.

bool Pipe::set_input_type char *  name  ) 
 

set the input conversion type for this Pipe

A Pipe can be of different types, meaning that it does different kind of operations when reading or writing like: conversions, mixing of various kinds, all opearations that we can optimize when doing in one single pass, while data is flowing around. Implementations of the various types available can be obtained looking into pipe.cpp when the copy callback functions are registered. The set_input_type and set_output_type methods are used to set which kind of operation the Pipe will execute when moving in and out the data. Default is "copy_byte" which simply copies one byte each sample, you want to change this to set it to the sample type you are using

types available: copy_byte copy_int16_to_float int to float using /32768.0f copy_float_to_int16 float to int using lrintf() mix_int16_to_int32 simple sum of 16bit over 32bit int

Definition at line 102 of file pipe.cpp.

bool Pipe::set_output_type char *  name  ) 
 

set the output conversion type for this Pipe

Definition at line 114 of file pipe.cpp.

int Pipe::size  ) 
 

tell the amount of data contained in the Pipe

Returns:
amount in bytes

Definition at line 343 of file pipe.cpp.

int Pipe::space  ) 
 

tell the amount of free space in the Pipe

Returns:
amount in bytes

Definition at line 355 of file pipe.cpp.

int Pipe::write int  length,
void *  data
 

< read from the pipe into a bidimensional float array Mix audio from FIFO pipe into a mixing buffer write into FIFO pipe

Write data inside the FIFO pipe, locking to not overlap read operations (thread safe).

Parameters:
length amount of bytes of data to be written
data buffer from where to take the data to be written
Returns:
when Pipe::blocking is set, this functions returns -1, otherwise the amount of data written.

Definition at line 259 of file pipe.cpp.


Member Data Documentation

bool Pipe::blocking
 

Definition at line 218 of file pipe.h.


The documentation for this class was generated from the following files: