| 6 |
| 7 | #ifndef LIBTGVOIP_AUDIOINPUTPULSE_H |
| 8 | #define LIBTGVOIP_AUDIOINPUTPULSE_H |
| 9 |
| 10 | #include "../../audio/AudioInput.h" |
| 11 | #include "../../threading.h" |
| 12 | #include <pulse/pulseaudio.h> |
| 13 |
| 14 | #define DECLARE_DL_FUNCTION(name) typeof(name)* _import_##name |
| 15 |
| 16 | namespace tgvoip{ |
| 17 | namespace audio{ |
| 18 |
| 19 | class AudioInputPulse : public AudioInput{ |
| 20 | public: |
| 21 | AudioInputPulse(pa_context* context, pa_threaded_mainloop* mainloop, std::string devID); |
| 22 | virtual ~AudioInputPulse(); |
| 23 | virtual void Start(); |
| 24 | virtual void Stop(); |
| 25 | virtual bool IsRecording(); |
| 26 | virtual void SetCurrentDevice(std::string devID); |
| 27 | static bool EnumerateDevices(std::vector<AudioInputDevice>& devs); |
| 28 |
| 29 | private: |
| 30 | static void StreamStateCallback(pa_stream* s, void* arg); |
| 31 | static void StreamReadCallback(pa_stream* stream, size_t requested_bytes, void* userdata); |
| 32 | void StreamReadCallback(pa_stream* stream, size_t requestedBytes); |
| 33 | pa_stream* CreateAndInitStream(); |
| 34 |
| 35 | pa_threaded_mainloop* mainloop; |
| 36 | pa_context* context; |
| 37 | pa_stream* stream; |
| 38 |
| 39 | bool isRecording; |
| 40 | bool isConnected; |
| 41 | bool didStart; |
| 42 | bool isLocked; |
| 43 | unsigned char remainingData[960*8*2]; |
| 44 | size_t remainingDataSize; |
| 45 | }; |
| 46 |
| 47 | } |
| 48 | } |
| 49 |
| 50 | #undef DECLARE_DL_FUNCTION |
| 51 |
| 52 | #endif //LIBTGVOIP_AUDIOINPUTPULSE_H |
| 53 |