class AlsaDspSource

An audio input based on the ALSA sound system More...

Definition#include <AlsaDspSource.h>
InheritsAudioSource [public ], Reporter [public virtual ]
List of all Methods
Annotated List
Files
Globals
Hierarchy
Index

Public Methods

Protected Methods

Private Members


Detailed Description

An audio input based on the ALSA sound system

char * pcmName

pcmName

[private]

snd_pcm_t * captureHandle

captureHandle

[private]

int bytesPerFrame

bytesPerFrame

[private]

bool running

running

[private]

unsigned int bufferTime

bufferTime

[private]

inline  AlsaDspSource ( void )
throw ( Exception )

AlsaDspSource

[protected]

Default constructor. Always throws an Exception.

Throws: Exception

void  init ( const char * name )
throw ( Exception )

init

[protected]

Initialize the object

Parameters:
namethe PCM to open.

Throws: Exception

Reimplemented from AudioSource.

void  strip ( void )
throw ( Exception )

strip

[protected]

De-iitialize the object

Throws: Exception

Reimplemented from AudioSource.

inline  AlsaDspSource ( const char * name, int sampleRate = 44100, int bitsPerSample = 16, int channel = 2 )
throw ( Exception )

AlsaDspSource

Constructor.

Parameters:
namethe PCM (e.g. "hwplug:0,0").
sampleRatesamples per second (e.g. 44100 for 44.1kHz).
bitsPerSamplebits per sample (e.g. 16 bits).
channelnumber of channels of the audio source (e.g. 1 for mono, 2 for stereo, etc.).

Throws: Exception

inline  AlsaDspSource ( const AlsaDspSource & ds )
throw ( Exception )

AlsaDspSource

Copy Constructor.

Parameters:
sourcethe object to copy.

Throws: Exception

inline  ~AlsaDspSource ( void )
throw ( Exception )

~AlsaDspSource

[virtual]

Destructor.

Throws: Exception

inline AlsaDspSource &  operator= ( const AlsaDspSource & ds )
throw ( Exception )

operator=

[virtual]

Assignment operator.

Parameters:
dsthe object to assign to this one.

Returns: a reference to this object.

Throws: Exception

Reimplemented from AudioSource.

bool  isBigEndian ( void )
throw ()

isBigEndian

[const virtual]

Tell if the data from this source comes in big or little endian.

Returns: true if the source is big endian, false otherwise

Reimplemented from AudioSource.

bool  open ( void )
throw ( Exception )

open

[virtual]

Open the AlsaDspSource. This does not put Alsa device into recording mode. To start getting samples, call either canRead() or read().

Returns: true if opening was successful, false otherwise

Throws: Exception

See also: canRead, read

Reimplemented from Source.

inline bool  isOpen ( void )
throw ()

isOpen

[const virtual]

Check if the AlsaDspSource is open.

Returns: true if the AlsaDspSource is open, false otherwise.

Reimplemented from Source.

bool  canRead ( unsigned int sec, unsigned int usec )
throw ( Exception )

canRead

[virtual]

Check if the AlsaDspSource can be read from. Blocks until the specified time for data to be available. Puts the PCM into recording mode.

Parameters:
secthe maximum seconds to block.
usecmicro seconds to block after the full seconds.

Returns: true if the AlsaDspSource is ready to be read from, false otherwise.

Throws: Exception

Reimplemented from Source.

unsigned int  read ( void * buf, unsigned int len )
throw ( Exception )

read

[virtual]

Read from the AlsaDspSource. Puts the PCM into recording mode.

Parameters:
bufthe buffer to read into.
lenthe number of bytes to read into buf

Returns: the number of bytes read (may be less than len).

Throws: Exception

Reimplemented from Source.

void  close ( void )
throw ( Exception )

close

[virtual]

Close the AlsaDspSource.

Throws: Exception

Reimplemented from Source.

inline unsigned int  getBufferTime ( void )

getBufferTime

[const virtual]

Returns the buffer size in useconds.

Returns: the number of useconds audio will be buffered in ALSA

inline void  setBufferTime ( unsigned int time )

setBufferTime

[virtual]

Sets the number of useconds to buffer audio in ALSA

Parameters:
timebuffer time