Etterna 0.74.4
Loading...
Searching...
No Matches
ALSA9Helpers.h
1#ifndef ALSA9_HELPERS_H
2#define ALSA9_HELPERS_H
3
4#define ALSA_PCM_NEW_HW_PARAMS_API
5#define ALSA_PCM_NEW_SW_PARAMS_API
6#include <alsa/asoundlib.h>
7
9{
10 private:
11 int channels, samplebits;
12 unsigned samplerate;
13 int buffersize;
14 int64_t last_cursor_pos;
15
16 snd_pcm_uframes_t preferred_writeahead, preferred_chunksize;
17 snd_pcm_uframes_t writeahead, chunksize;
18
19 snd_pcm_t* pcm;
20
21 bool Recover(int r);
22 bool SetHWParams();
23 bool SetSWParams();
24
25 static void ErrorHandler(const char* file,
26 int line,
27 const char* function,
28 int err,
29 const char* fmt,
30 ...);
31
32 public:
33 static void InitializeErrorHandler();
34 static void GetSoundCardDebugInfo();
35 static std::string GetHardwareID(std::string name = "");
36
37 Alsa9Buf();
38 std::string Init(int channels,
39 int iWriteahead,
40 int iChunkSize,
41 int iSampleRate);
42 ~Alsa9Buf();
43
44 int GetNumFramesToFill();
45 bool WaitUntilFramesCanBeFilled(int timeout_ms);
46 void Write(const int16_t* buffer, int frames);
47
48 void Play();
49 void Stop();
50 void SetVolume(float vol);
51 int GetSampleRate() const { return samplerate; }
52
53 int64_t GetPosition() const;
54 int64_t GetPlayPos() const { return last_cursor_pos; }
55};
56#endif
Definition ALSA9Helpers.h:9