26 void init(
const char *devName){
27 int err=
Stream::init(devName, SND_PCM_STREAM_CAPTURE,
block ? 0 : SND_PCM_NONBLOCK);
29 std::cout<<err<<std::endl;
30 std::cerr<<
"Capture :: Capture : open error: "<< snd_strerror(err)<<std::endl;
57 ret = snd_pcm_readi(
getPCM(), buffer, len);
64 printf(
"Capture::readbuf : PCM state %s\n",
getStateName());
72 std::cout<<
"read error "<<ret<<
'\n';
75 if (ret==0 &&
block!=0)
77 buffer+= ret*bytes_per_frame;
86 template <
typename Derived>
87 int readBuf(
const Eigen::DenseBase<Derived> &audioData){
88 return readBuf((
char*)&audioData(0,0), audioData.rows());
95 template <
typename Derived>
void init(const char *devName)
#define PCM_NOT_OPEN_CHECK_NO_PRINT(pcm, type)
virtual snd_pcm_t * getPCM()
int readBuf(char *buffer, size_t len)
Capture & operator>>(const Eigen::DenseBase< Derived > &audioData)
const char * getStateName()
int init(const char *device, snd_pcm_stream_t streamType, bool blockIn)
Capture(const char *devName)
int readBuf(const Eigen::DenseBase< Derived > &audioData)
virtual int evaluateError(int errorNum)
int getFormatPhysicalWidth()
int wait(int timeOut=1000)
#define ALSA_UNKNOWN_READ_ERROR
error when reading and an unknown code is retured