35 #include <boost/format.hpp> 37 # include <portaudio.h> 38 # define PORTAUDIO_DEF 40 # define PORTAUDIO_DEF { throw SoDa::SoDaException("PortAudio Library is not enabled in this build version."); } 93 int recv(
void * buf,
unsigned int len,
bool block =
true) { (void) buf; (void) len; (void) block;
PORTAUDIO_DEF }
107 #if HAVE_LIBPORTAUDIO 108 pa_stat = Pa_StopStream(pa_outstream);
109 if(pa_stat != paStreamIsStopped) checkStatus(pa_stat,
"sleepOut");
116 #if HAVE_LIBPORTAUDIO 117 pa_stat = Pa_StartStream(pa_outstream);
118 if(pa_stat != paStreamIsNotStopped) checkStatus(pa_stat,
"wakeOut");
127 #if HAVE_LIBPORTAUDIO 128 pa_stat = Pa_StopStream(pa_instream);
129 if(pa_stat != paStreamIsStopped) checkStatus(pa_stat,
"sleepIn");
136 #if HAVE_LIBPORTAUDIO 137 pa_stat = Pa_StartStream(pa_instream);
138 if(pa_stat != paStreamIsNotStopped) checkStatus(pa_stat,
"wakeIn");
143 #if HAVE_LIBPORTAUDIO 144 PaStream * pa_instream;
145 PaStream * pa_outstream;
163 #if HAVE_LIBPORTAUDIO 164 void checkStatus(PaError v,
const std::string & exp,
bool fatal =
false) {
166 if (v != paNoError) {
167 if(fatal)
throw SoDaException((boost::format(
"%s %s") % exp % Pa_GetErrorText(v)).str(),
this);
168 else std::cerr << boost::format(
"%s: %s %s\n") %
getObjName() % exp % Pa_GetErrorText(v);
The Baseclass for all SoDa objects, and useful commonly used classes.
std::string & getObjName()
get the name of this object
int send(void *buf, unsigned int len)
sendBuf – send a buffer to the audio output
The SoDa Exception class.
void sleepOut()
stop the output stream so that we don't encounter a buffer underflow while the reciever is muted...
the PortAudio interface class
int recv(void *buf, unsigned int len, bool block=true)
recvBuf – get a buffer of data from the audio input
bool sendBufferReady(unsigned int len)
sendBufferReady – is there enough space in the audio device send buffer for a call from send...
bool recvBufferReady(unsigned int len)
recvBufferReady – is there enough space in the audio device recv buffer for a call from recv...
void wakeOut()
start the output stream
Generic Audio Interface Class.
void sleepIn()
stop the input stream so that we don't encounter a buffer overflow while the transmitter is inactive...
AudioPA(unsigned int _sample_rate, AudioIfc::DataFormat _fmt, unsigned int _sample_count_hint=1024)
constructor
void wakeIn()
start the input stream