diff options
Diffstat (limited to 'src/audio/manager.hpp')
-rw-r--r-- | src/audio/manager.hpp | 41 |
1 files changed, 40 insertions, 1 deletions
diff --git a/src/audio/manager.hpp b/src/audio/manager.hpp index 5716fc5..a657dcc 100644 --- a/src/audio/manager.hpp +++ b/src/audio/manager.hpp @@ -11,7 +11,13 @@ #include <unordered_map> #include <unordered_set> #include <vector> + +#ifndef USE_PORTAUDIO #include <miniaudio.h> +#else +#include <portaudio.h> +#endif + #include <opus.h> #include <sigc++/sigc++.h> #include <spdlog/spdlog.h> @@ -80,7 +86,9 @@ public: void SetVADMethod(VADMethod method); VADMethod GetVADMethod() const; +#ifndef USE_PORTAUDIO static std::vector<ma_backend> ParseBackendsList(const Glib::ustring &list); +#endif /* USE_PORTAUDIO */ #ifdef WITH_RNNOISE float GetCurrentVADProbability() const; @@ -94,10 +102,18 @@ public: bool GetMixMono() const; private: +#ifndef USE_PORTAUDIO void OnCapturedPCM(const int16_t *pcm, ma_uint32 frames); +#else /* USE_PORTAUDIO */ + void OnCapturedPCM(const int16_t *pcm, uint32_t frames); +#endif /* USE_PORTAUDIO */ void UpdateReceiveVolume(uint32_t ssrc, const int16_t *pcm, int frames); +#ifndef USE_PORTAUDIO void UpdateCaptureVolume(const int16_t *pcm, ma_uint32 frames); +#else + void UpdateCaptureVolume(const int16_t *pcm, uint32_t frames); +#endif /* USE_PORTAUDIO */ std::atomic<int> m_capture_peak_meter = 0; bool DecayVolumeMeters(); @@ -111,13 +127,24 @@ private: void RNNoiseUninitialize(); #endif +#ifndef USE_PORTAUDIO friend void data_callback(ma_device *, void *, const void *, ma_uint32); friend void capture_data_callback(ma_device *, void *, const void *, ma_uint32); +#else /* USE_PORTAUDIO */ + friend int playCallback(const void *pInput, void *pOutput, unsigned long frameCount, + const PaStreamCallbackTimeInfo* timeInfo, PaStreamCallbackFlags statusFlags, void *userData ); + friend int recordCallback(const void *pInput, void *pOutput, + unsigned long frameCount, + const PaStreamCallbackTimeInfo* timeInfo, + PaStreamCallbackFlags statusFlags, + void *userData ); +#endif /* USE_PORTAUDIO */ std::thread m_thread; bool m_ok; +#ifndef USE_PORTAUDIO // playback ma_device m_playback_device; ma_device_config m_playback_config; @@ -126,8 +153,18 @@ private: ma_device m_capture_device; ma_device_config m_capture_config; ma_device_id m_capture_id; - + ma_context m_context; +#else + // playback + PaStream* pa_playback_device; + PaStreamParameters m_playback_config; + // capture + PaStream* pa_capture_device; + PaStreamParameters m_capture_config; + +#endif + mutable std::mutex m_mutex; mutable std::mutex m_enc_mutex; @@ -166,7 +203,9 @@ private: #endif std::atomic<uint32_t> m_rtp_timestamp = 0; +#ifndef USE_PORTAUDIO ma_log m_ma_log; +#endif std::shared_ptr<spdlog::logger> m_log; public: |