SoDaRadio-5.0.3-master:8901fb5
|
ALSA audio interface class. More...
#include <AudioALSA.hxx>
Public Member Functions | |
AudioALSA (unsigned int _sample_rate, AudioIfc::DataFormat _fmt, unsigned int _sample_count_hint=1024, std::string audio_port_name=std::string("default")) | |
constructor More... | |
~AudioALSA () | |
int | send (void *buf, unsigned int len) |
send – send a buffer to the audio output More... | |
bool | sendBufferReady (unsigned int len) |
sendBufferReady – is there enough space in the audio device send buffer for a call from send? More... | |
int | recv (void *buf, unsigned int len, bool block=true) |
recv – get a buffer of data from the audio input More... | |
bool | recvBufferReady (unsigned int len) |
recvBufferReady – are there samples waiting in the audio device? More... | |
void | sleepOut () |
stop the output stream so that we don't encounter a buffer underflow while the reciever is muted. More... | |
void | wakeOut () |
start the output stream More... | |
void | sleepIn () |
stop the input stream so that we don't encounter a buffer overflow while the transmitter is inactive. More... | |
void | wakeIn () |
start the input stream More... | |
Public Member Functions inherited from SoDa::AudioIfc | |
AudioIfc (unsigned int _sample_rate, DataFormat _fmt, unsigned int _sample_count_hint, const std::string &name="AudioIfc") | |
virtual bool | setOutGain (float gain) |
set the gain for the output device. More... | |
virtual bool | setInGain (float gain) |
set the gain for the input device. More... | |
virtual float | getOutGain () |
get the gain for the output device. More... | |
virtual float | getInGain () |
get the gain for the input device. More... | |
virtual std::string | currentPlaybackState () |
virtual std::string | currentCaptureState () |
Public Member Functions inherited from SoDa::SoDaBase | |
SoDaBase (const std::string &oname) | |
The constructor – pass a name for the object. More... | |
std::string & | getObjName () |
get the name of this object More... | |
SoDaBase * | findSoDaObject (const std::string &oname) |
find a SoDa Object by name. More... | |
double | getTime () |
Get a time stamp in nS resolution that monotonically increases and that is very inexpensive (typically < 100nS). More... | |
Additional Inherited Members | |
Public Types inherited from SoDa::AudioIfc | |
enum | DataFormat { FLOAT, DFLOAT, INT32, INT16, INT8 } |
Protected Attributes inherited from SoDa::AudioIfc | |
unsigned int | sample_rate |
DataFormat | format |
unsigned int | sample_count_hint |
float | in_gain |
float | out_gain |
int | datatype_size |
ALSA audio interface class.
AudioALSA implements the interface specified by AudioIfc. It should be interchangable with other audio interface handlers.
The first several generations of SoDa used a Port Audio interface, but the PA library tends to spew a lot of extraneous "informational" messages on the console. Though it is quite simple, the noise that PA creates makes it not my (kb1vc) interface of choice.
ALSA on the other hand is documented poorly, organized oddly, and nearly inscrutable. But it is fast, and doesn't make a lot of noise on the console.
Definition at line 63 of file AudioALSA.hxx.
SoDa::AudioALSA::AudioALSA | ( | unsigned int | _sample_rate, |
AudioIfc::DataFormat | _fmt, | ||
unsigned int | _sample_count_hint = 1024 , |
||
std::string | audio_port_name = std::string("default") |
||
) |
constructor
_sample_rate | in Hz 48000 is a good choice |
_fmt | the format of the data (FLOAT, DFLOAT, INT32, INT16, INT8) |
_sample_count_hint | the size of the buffers passed to and from the audio device (in samples) |
audio_port_name | which ALSA device are we connecting to? |
Definition at line 254 of file AudioALSA.cxx.
|
inline |
Definition at line 78 of file AudioALSA.hxx.
|
inlinevirtual |
recv – get a buffer of data from the audio input
buf | buffer of type described by the DataFormat selected at init |
len | number of elements in the buffer to get |
block | make this a blocking call — ignored. |
Implements SoDa::AudioIfc.
Definition at line 107 of file AudioALSA.hxx.
|
inlinevirtual |
recvBufferReady – are there samples waiting in the audio device?
len | the number of samples that we wish to get |
Implements SoDa::AudioIfc.
Definition at line 115 of file AudioALSA.hxx.
|
inlinevirtual |
send – send a buffer to the audio output
buf | buffer of type described by the DataFormat selected at init |
len | number of elements in the buffer to send |
Implements SoDa::AudioIfc.
Definition at line 90 of file AudioALSA.hxx.
|
inlinevirtual |
sendBufferReady – is there enough space in the audio device send buffer for a call from send?
len | the number of samples that we wish to send |
Implements SoDa::AudioIfc.
Definition at line 98 of file AudioALSA.hxx.
|
inlinevirtual |
stop the input stream so that we don't encounter a buffer overflow while the transmitter is inactive.
Implements SoDa::AudioIfc.
Definition at line 149 of file AudioALSA.hxx.
|
inlinevirtual |
stop the output stream so that we don't encounter a buffer underflow while the reciever is muted.
Implements SoDa::AudioIfc.
Definition at line 121 of file AudioALSA.hxx.
|
inlinevirtual |
start the input stream
Implements SoDa::AudioIfc.
Definition at line 169 of file AudioALSA.hxx.
References SoDa::AudioIfc::currentCaptureState(), SoDa::AudioIfc::currentPlaybackState(), and SoDa::SoDaBase::getObjName().
|
inlinevirtual |