#ifndef ALSA_PCM__H #define ALSA_PCM__H #include #include const int FPP(1024); // frames per period class alsa_pcm{ public: snd_pcm_t* phndl; // pcm handle #if 0 DO NOT save a pointer to any snd_pcm_hw_params_t object; alsa allocates space _on the stack_ and it goes out of scope quickly. snd_pcm_hw_params_t *hwparams; #endif snd_output_t* errlog; unsigned int nchan; // samples per frame; 2 ==> stereo unsigned int max_rate; unsigned int rate; // frames per second int sbits; // significant bits snd_pcm_stream_t direction; // int sizeofsamp; // bytes per sample snd_pcm_format_t format; const char* moniker; snd_htimestamp_t ss_time(); // start or stop time (usually start time) snd_htimestamp_t now(); // current time void error(const char*, const int, snd_pcm_hw_params_t*); int getrate(const std::string carddevice, snd_pcm_stream_t stream_dir, const int dumpflag); int setup(const int rate); // Constructor doesn't do much, // so it is cheap to allocate one that you're not // necessarily going to use: inline alsa_pcm(const char* mm) : phndl(0), errlog(0), moniker(mm) {} int try_formats(snd_pcm_hw_params_t*); std::string alsa_state_name(); }; void device_list(const snd_pcm_stream_t direction); #endif /* ALSA_PCM__H */