|
|
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:
name | the 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:
name | the PCM (e.g. "hwplug:0,0"). |
sampleRate | samples per second (e.g. 44100 for 44.1kHz). |
bitsPerSample | bits per sample (e.g. 16 bits). |
channel | number 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:
source | the 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:
ds | the 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
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:
sec | the maximum seconds to block. |
usec | micro 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:
buf | the buffer to read into. |
len | the 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:
time | buffer time |