36 int init(
const char *device, snd_pcm_stream_t streamType,
bool blockIn) {
38 int ret=
open(device, streamType, block ? 0 : SND_PCM_NONBLOCK);
40 std::cerr<<
"Couldn't open device"<<std::endl;
48 if ((ret=
setAccess(SND_PCM_ACCESS_RW_INTERLEAVED))<0){
49 std::cerr<<
"Couldn't setAccess"<<std::endl;
53 std::cerr<<
"Couldn't setFormat"<<std::endl;
57 std::cerr<<
"Couldn't setChannels"<<std::endl;
63 std::cerr<<
"Couldn't setSampleRate"<<std::endl;
79 return snd_pcm_format_name(format);
88 int open(
const char *device, snd_pcm_stream_t streamType,
const int block) {
89 std::cout<<
"opening the device "<<device<<std::endl;
91 if ((ret=
PCM::open(device, streamType, block))<0)
94 std::cerr<<
"Couldn't fillParams "<<snd_strerror(ret)<<std::endl;
114 snd_pcm_uframes_t val = 4;
133 snd_pcm_format_t format;
137 return snd_pcm_format_set_silence(format, data, samples);
160 return snd_pcm_wait(
getPCM(), timeOut);
167 snd_pcm_format_t format;
170 return snd_pcm_format_width(format);
int setSampleRate(unsigned int rrate, int dir=0)
int getPeriodSize(snd_pcm_uframes_t *p, int *dir=NULL)
int open(const char *device, snd_pcm_stream_t streamType, const int block)
bool block
Whether to block or use NONBLOCK.
#define ALSA_DEFAULT_CHANNELS
virtual snd_pcm_t * getPCM()
int init(const char *device, snd_pcm_stream_t streamType, bool blockIn)
#define ALSA_DEFAULT_FORMAT
int setAccess(snd_pcm_access_t access)
int getFormat(snd_pcm_format_t &format)
virtual int evaluateError(int errorNum)
#define ALSA_DEFAULT_START_FS
#define PCM_NOT_OPEN_CHECK(pcm)
int open(const char *device, snd_pcm_stream_t streamType, const int block)
int setSilence(void *data, unsigned int samples)
Silence a PCM samples buffer.
int setSWThreshold(snd_pcm_uframes_t thresh)
int wait(int timeOut=1000)
const char * getFormatName(const snd_pcm_format_t format)
get name of PCM sample format
int setFormat(snd_pcm_format_t format)
int setChannels(unsigned int cnt)
virtual ~Stream()
Destructor.
int setAvailMin(snd_pcm_uframes_t cnt)