X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=alsa_output.h;fp=alsa_output.h;h=12af16ecbfdd9ade616805fea169f7004899b0ff;hb=194872611b21bb070f4dfcf5beda6c36d25459ea;hp=0000000000000000000000000000000000000000;hpb=beaf0e95b0e474c3088ee8ee74191b6c504fef82;p=nageru diff --git a/alsa_output.h b/alsa_output.h new file mode 100644 index 0000000..12af16e --- /dev/null +++ b/alsa_output.h @@ -0,0 +1,27 @@ +#ifndef _ALSA_OUTPUT_H +#define _ALSA_OUTPUT_H 1 + +// Extremely minimalistic ALSA output. Will not resample to fit +// sound card clock, will not care much about over- or underflows +// (so it will not block), will not care about A/V sync. +// +// This means that if you run it for long enough, clocks will +// probably drift out of sync enough to make a little pop. + +#include + +#include + +class ALSAOutput { +public: + ALSAOutput(int sample_rate, int num_channels); + void write(const std::vector &samples); + +private: + snd_pcm_t *pcm_handle; + std::vector buffer; + snd_pcm_uframes_t period_size; + int num_channels; +}; + +#endif // !defined(_ALSA_OUTPUT_H)