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