]> git.sesse.net Git - nageru/blob - alsa_output.h
Fix an issue where the mixer lagging too much behind CEF would cause us to display...
[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 #include <vector>
13
14 class ALSAOutput {
15 public:
16         ALSAOutput(int sample_rate, int num_channels);
17         void write(const std::vector<float> &samples);
18
19 private:
20         snd_pcm_t *pcm_handle;
21         std::vector<float> buffer;
22         snd_pcm_uframes_t period_size;
23         int sample_rate, num_channels;
24 };
25
26 #endif  // !defined(_ALSA_OUTPUT_H)