AudioOutputPulse.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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_AUDIOOUTPUTPULSE_H
  7. #define LIBTGVOIP_AUDIOOUTPUTPULSE_H
  8. #include "../../audio/AudioOutput.h"
  9. #include "../../threading.h"
  10. #include <pulse/pulseaudio.h>
  11. namespace tgvoip{
  12. namespace audio{
  13. class AudioOutputPulse : public AudioOutput{
  14. public:
  15. AudioOutputPulse(pa_context* context, pa_threaded_mainloop* mainloop, std::string devID);
  16. virtual ~AudioOutputPulse();
  17. virtual void Start();
  18. virtual void Stop();
  19. virtual bool IsPlaying();
  20. virtual void SetCurrentDevice(std::string devID);
  21. static bool EnumerateDevices(std::vector<AudioOutputDevice>& devs);
  22. private:
  23. static void StreamStateCallback(pa_stream* s, void* arg);
  24. static void StreamWriteCallback(pa_stream* stream, size_t requested_bytes, void* userdata);
  25. void StreamWriteCallback(pa_stream* stream, size_t requestedBytes);
  26. pa_stream* CreateAndInitStream();
  27. pa_threaded_mainloop* mainloop;
  28. pa_context* context;
  29. pa_stream* stream;
  30. bool isPlaying;
  31. bool isConnected;
  32. bool didStart;
  33. bool isLocked;
  34. unsigned char remainingData[960*8*2];
  35. size_t remainingDataSize;
  36. };
  37. }
  38. }
  39. #endif //LIBTGVOIP_AUDIOOUTPUTPULSE_H