summaryrefslogtreecommitdiffstats
path: root/src/AlsaInput.h
diff options
context:
space:
mode:
authorMatthias P. Braendli <matthias.braendli@mpb.li>2017-10-07 11:47:05 +0200
committerMatthias P. Braendli <matthias.braendli@mpb.li>2017-10-07 11:51:46 +0200
commit84febca8b268129cdd79ff0d1c4f8eeed092c5fb (patch)
tree3e75880241e0fcd2951c04aad77d7077b4ec130c /src/AlsaInput.h
parent9c2615425bb4f35a417eb04b1ceebfc77d8e2c8b (diff)
downloadODR-AudioEnc-84febca8b268129cdd79ff0d1c4f8eeed092c5fb.tar.gz
ODR-AudioEnc-84febca8b268129cdd79ff0d1c4f8eeed092c5fb.tar.bz2
ODR-AudioEnc-84febca8b268129cdd79ff0d1c4f8eeed092c5fb.zip
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.
Diffstat (limited to 'src/AlsaInput.h')
-rw-r--r--src/AlsaInput.h24
1 files changed, 15 insertions, 9 deletions
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<uint8_t>& 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<uint8_t>& 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<uint8_t>& 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<uint8_t>& 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<bool> m_running;
std::thread m_thread;
- SampleQueue<uint8_t>& m_queue;
-
};
#endif // HAVE_ALSA