| 6 |
| 7 | #ifndef LIBTGVOIP_AUDIOOUTPUTALSA_H |
| 8 | #define LIBTGVOIP_AUDIOOUTPUTALSA_H |
| 9 |
| 10 | #include "../../audio/AudioOutput.h" |
| 11 | #include "../../threading.h" |
| 12 | #include <alsa/asoundlib.h> |
| 13 |
| 14 | namespace tgvoip |
| 15 | { |
| 16 |
| 17 | namespace audio |
| 18 | { |
| 19 |
| 20 | class AudioOutputALSA : public AudioOutput |
| 21 | { |
| 22 | public: |
| 23 | AudioOutputALSA(std::string devID); |
| 24 | virtual ~AudioOutputALSA(); |
| 25 | virtual void Start(); |
| 26 | virtual void Stop(); |
| 27 | virtual bool IsPlaying(); |
| 28 | virtual void SetCurrentDevice(std::string devID); |
| 29 | static void EnumerateDevices(std::vector<AudioOutputDevice>& devs); |
| 30 |
| 31 | private: |
| 32 | void RunThread(); |
| 33 |
| 34 | int (*m_snd_pcm_open)(snd_pcm_t** pcm, const char* name, snd_pcm_stream_t stream, int mode); |
| 35 | int (*m_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); |
| 36 | int (*m_snd_pcm_close)(snd_pcm_t* pcm); |
| 37 | snd_pcm_sframes_t (*m_snd_pcm_writei)(snd_pcm_t* pcm, const void* buffer, snd_pcm_uframes_t size); |
| 38 | int (*m_snd_pcm_recover)(snd_pcm_t* pcm, int err, int silent); |
| 39 | const char* (*m_snd_strerror)(int errnum); |
| 40 | void* m_lib; |
| 41 |
| 42 | snd_pcm_t* m_handle; |
| 43 | Thread* m_thread; |
| 44 | bool m_isPlaying; |
| 45 | }; |
| 46 |
| 47 | } // namespace audio |
| 48 |
| 49 | } // namespace tgvoip |
| 50 |
| 51 | #endif // LIBTGVOIP_AUDIOOUTPUTALSA_H |
| 52 |