AudioInputALSA.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. //
  2. // libtgvoip is free and unencumbered public domain software.
  3. // For more information, see http://unlicense.org or the UNLICENSE file
  4. // you should have received with this source code distribution.
  5. //
  6. #ifndef LIBTGVOIP_AUDIOINPUTALSA_H
  7. #define LIBTGVOIP_AUDIOINPUTALSA_H
  8. #include "../../audio/AudioInput.h"
  9. #include "../../threading.h"
  10. #include <alsa/asoundlib.h>
  11. namespace tgvoip{
  12. namespace audio{
  13. class AudioInputALSA : public AudioInput{
  14. public:
  15. AudioInputALSA(std::string devID);
  16. virtual ~AudioInputALSA();
  17. virtual void Start();
  18. virtual void Stop();
  19. virtual void SetCurrentDevice(std::string devID);
  20. static void EnumerateDevices(std::vector<AudioInputDevice>& devs);
  21. private:
  22. void RunThread();
  23. int (*_snd_pcm_open)(snd_pcm_t** pcm, const char* name, snd_pcm_stream_t stream, int mode);
  24. 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);
  25. int (*_snd_pcm_close)(snd_pcm_t* pcm);
  26. snd_pcm_sframes_t (*_snd_pcm_readi)(snd_pcm_t *pcm, const void *buffer, snd_pcm_uframes_t size);
  27. int (*_snd_pcm_recover)(snd_pcm_t* pcm, int err, int silent);
  28. const char* (*_snd_strerror)(int errnum);
  29. void* lib;
  30. snd_pcm_t* handle;
  31. Thread* thread;
  32. bool isRecording;
  33. };
  34. }
  35. }
  36. #endif //LIBTGVOIP_AUDIOINPUTALSA_H