]> git.sesse.net Git - nageru/blob - alsa_output.h
If a dead device comes back, put it into the right slot.
[nageru] / alsa_output.h
1 #ifndef _ALSA_OUTPUT_H
2 #define _ALSA_OUTPUT_H 1
3
4 // Extremely minimalistic ALSA output. Will not resample to fit
5 // sound card clock, will not care much about over- or underflows
6 // (so it will not block), will not care about A/V sync.
7 //
8 // This means that if you run it for long enough, clocks will
9 // probably drift out of sync enough to make a little pop.
10
11 #include <alsa/asoundlib.h>
12
13 #include <vector>
14
15 class ALSAOutput {
16 public:
17         ALSAOutput(int sample_rate, int num_channels);
18         void write(const std::vector<float> &samples);
19
20 private:
21         snd_pcm_t *pcm_handle;
22         std::vector<float> buffer;
23         snd_pcm_uframes_t period_size;
24         int sample_rate, num_channels;
25 };
26
27 #endif  // !defined(_ALSA_OUTPUT_H)