blob: fafd857978bcd304ba253630fe569d07194bd192 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
#ifndef ALSA_PCM__H
#define ALSA_PCM__H
#include <string>
#include <alsa/asoundlib.h>
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 */
|