| 6 |
| 7 | #ifndef LIBTGVOIP_AUDIOINPUTALSA_H |
| 8 | #define LIBTGVOIP_AUDIOINPUTALSA_H |
| 9 |
| 10 | #include "../../audio/AudioInput.h" |
| 11 | #include "../../threading.h" |
| 12 | #include <alsa/asoundlib.h> |
| 13 |
| 14 | namespace tgvoip{ |
| 15 | namespace audio{ |
| 16 |
| 17 | class AudioInputALSA : public AudioInput{ |
| 18 |
| 19 | public: |
| 20 | AudioInputALSA(std::string devID); |
| 21 | virtual ~AudioInputALSA(); |
| 22 | virtual void Start(); |
| 23 | virtual void Stop(); |
| 24 | virtual void SetCurrentDevice(std::string devID); |
| 25 | static void EnumerateDevices(std::vector<AudioInputDevice>& devs); |
| 26 |
| 27 | private: |
| 28 | void RunThread(); |
| 29 |
| 30 | int (*_snd_pcm_open)(snd_pcm_t** pcm, const char* name, snd_pcm_stream_t stream, int mode); |
| 31 | int (*_snd_pcm_set_params)(snd_pcm_t* pcm, snd_pcm_format_t format, snd_pcm_access_t access, unsigned int channels, unsigned int rate, int soft_resample, unsigned int latency); |
| 32 | int (*_snd_pcm_close)(snd_pcm_t* pcm); |
| 33 | snd_pcm_sframes_t (*_snd_pcm_readi)(snd_pcm_t *pcm, const void *buffer, snd_pcm_uframes_t size); |
| 34 | int (*_snd_pcm_recover)(snd_pcm_t* pcm, int err, int silent); |
| 35 | const char* (*_snd_strerror)(int errnum); |
| 36 | void* lib; |
| 37 |
| 38 | snd_pcm_t* handle; |
| 39 | Thread* thread; |
| 40 | bool isRecording; |
| 41 | }; |
| 42 |
| 43 | } |
| 44 | } |
| 45 |
| 46 | #endif //LIBTGVOIP_AUDIOINPUTALSA_H |
| 47 |