summaryrefslogtreecommitdiffstats
path: root/src/AlsaInput.h
diff options
context:
space:
mode:
authorMatthias P. Braendli <matthias.braendli@mpb.li>2014-04-25 17:32:03 +0200
committerMatthias P. Braendli <matthias.braendli@mpb.li>2014-04-25 17:32:03 +0200
commita8bd9b19bba683031f6c7a68e9e6ca653be18d6c (patch)
treedfa89c850438c59cce40897a29287eeb1978f31b /src/AlsaInput.h
parent8f13b3f2580f182f51d9ad131da1deafdcd5e91a (diff)
downloadfdk-aac-dabplus-a8bd9b19bba683031f6c7a68e9e6ca653be18d6c.tar.gz
fdk-aac-dabplus-a8bd9b19bba683031f6c7a68e9e6ca653be18d6c.tar.bz2
fdk-aac-dabplus-a8bd9b19bba683031f6c7a68e9e6ca653be18d6c.zip
merge file and alsa encoders into dabplus-enc
There was a lot of redundant code between the two
Diffstat (limited to 'src/AlsaInput.h')
-rw-r--r--src/AlsaInput.h18
1 files changed, 8 insertions, 10 deletions
diff --git a/src/AlsaInput.h b/src/AlsaInput.h
index 0d454a3..bd3a800 100644
--- a/src/AlsaInput.h
+++ b/src/AlsaInput.h
@@ -27,18 +27,19 @@
#include "SampleQueue.h"
-using namespace std;
-
// 16 bits per sample is fine for now
#define BYTES_PER_SAMPLE 2
// How many samples we insert into the queue each call
#define NUM_SAMPLES_PER_CALL 10 // 10 samples @ 32kHz = 3.125ms
+/* Common functionality for the direct alsa input and the
+ * threaded alsa input
+ */
class AlsaInput
{
public:
- AlsaInput(const string& alsa_dev,
+ AlsaInput(const std::string& alsa_dev,
unsigned int channels,
unsigned int rate) :
m_alsa_dev(alsa_dev),
@@ -57,12 +58,10 @@ class AlsaInput
/* Prepare the audio input */
int prepare();
- virtual void start() = 0;
-
protected:
ssize_t m_read(uint8_t* buf, snd_pcm_uframes_t length);
- string m_alsa_dev;
+ std::string m_alsa_dev;
unsigned int m_channels;
unsigned int m_rate;
@@ -75,13 +74,11 @@ class AlsaInput
class AlsaInputDirect : public AlsaInput
{
public:
- AlsaInputDirect(const string& alsa_dev,
+ AlsaInputDirect(const std::string& alsa_dev,
unsigned int channels,
unsigned int rate) :
AlsaInput(alsa_dev, channels, rate) { }
- virtual void start() { };
-
/* Read length Bytes from from the alsa device.
* length must be a multiple of channels * bytes_per_sample.
*
@@ -97,7 +94,7 @@ class AlsaInputDirect : public AlsaInput
class AlsaInputThreaded : public AlsaInput
{
public:
- AlsaInputThreaded(const string& alsa_dev,
+ AlsaInputThreaded(const std::string& alsa_dev,
unsigned int channels,
unsigned int rate,
SampleQueue<uint8_t>& queue) :
@@ -115,6 +112,7 @@ class AlsaInputThreaded : public AlsaInput
}
}
+ /* Start the ALSA thread that fills the queue */
virtual void start();
bool fault_detected() { return m_fault; };