From 84febca8b268129cdd79ff0d1c4f8eeed092c5fb Mon Sep 17 00:00:00 2001 From: "Matthias P. Braendli" Date: Sat, 7 Oct 2017 11:47:05 +0200 Subject: Use queue for all inputs and unify interface This also changes the --fifo-silence option. Instead of inserting silence separately, it uses the drift compensation to do that. --- src/AlsaInput.h | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) (limited to 'src/AlsaInput.h') diff --git a/src/AlsaInput.h b/src/AlsaInput.h index 08ccbf6..e90ed36 100644 --- a/src/AlsaInput.h +++ b/src/AlsaInput.h @@ -47,10 +47,12 @@ class AlsaInput : public InputInterface public: AlsaInput(const std::string& alsa_dev, unsigned int channels, - unsigned int rate) : + unsigned int rate, + SampleQueue& queue) : m_alsa_dev(alsa_dev), m_channels(channels), - m_rate(rate) { } + m_rate(rate), + m_queue(queue) { } AlsaInput(const AlsaInput& other) = delete; AlsaInput& operator=(const AlsaInput& other) = delete; @@ -70,6 +72,8 @@ class AlsaInput : public InputInterface unsigned int m_channels; unsigned int m_rate; + SampleQueue& m_queue; + snd_pcm_t *m_alsa_handle = nullptr; }; @@ -78,8 +82,9 @@ class AlsaInputDirect : public AlsaInput public: AlsaInputDirect(const std::string& alsa_dev, unsigned int channels, - unsigned int rate) : - AlsaInput(alsa_dev, channels, rate) { } + unsigned int rate, + SampleQueue& queue) : + AlsaInput(alsa_dev, channels, rate, queue) { } #if 0 AlsaInputDirect(AlsaInputDirect&& other) : @@ -102,6 +107,8 @@ class AlsaInputDirect : public AlsaInput virtual bool fault_detected(void) const override { return false; }; + virtual bool read_source(size_t num_bytes) override; + /*! Read length Bytes from from the alsa device. * length must be a multiple of channels * bytes_per_sample. * @@ -117,10 +124,9 @@ class AlsaInputThreaded : public AlsaInput unsigned int channels, unsigned int rate, SampleQueue& queue) : - AlsaInput(alsa_dev, channels, rate), + AlsaInput(alsa_dev, channels, rate, queue), m_fault(false), - m_running(false), - m_queue(queue) { } + m_running(false) { } virtual ~AlsaInputThreaded() { @@ -135,6 +141,8 @@ class AlsaInputThreaded : public AlsaInput virtual bool fault_detected(void) const override { return m_fault; }; + virtual bool read_source(size_t num_bytes) override; + private: void process(); @@ -142,8 +150,6 @@ class AlsaInputThreaded : public AlsaInput std::atomic m_running; std::thread m_thread; - SampleQueue& m_queue; - }; #endif // HAVE_ALSA -- cgit v1.2.3