diff options
author | Matthias P. Braendli <matthias.braendli@mpb.li> | 2016-01-10 17:02:50 +0100 |
---|---|---|
committer | Matthias P. Braendli <matthias.braendli@mpb.li> | 2016-01-10 17:18:45 +0100 |
commit | e4821033a325b748c1c69848554b349c76ba6f59 (patch) | |
tree | 5626e72fc145e23ea5766984720c5adf643730d5 /src/VLCInput.h | |
parent | c36c65f341429d8b6412be23205f6f9d1b0c864c (diff) | |
download | ODR-AudioEnc-e4821033a325b748c1c69848554b349c76ba6f59.tar.gz ODR-AudioEnc-e4821033a325b748c1c69848554b349c76ba6f59.tar.bz2 ODR-AudioEnc-e4821033a325b748c1c69848554b349c76ba6f59.zip |
Add VLC variant with drift compensation
Diffstat (limited to 'src/VLCInput.h')
-rw-r--r-- | src/VLCInput.h | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/src/VLCInput.h b/src/VLCInput.h index 710a0c6..f880642 100644 --- a/src/VLCInput.h +++ b/src/VLCInput.h @@ -38,6 +38,9 @@ // 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 libvlc input and the * threaded libvlc input */ @@ -143,6 +146,47 @@ class VLCInputDirect : public VLCInput }; +class VLCInputThreaded : public VLCInput +{ + public: + VLCInputThreaded(const std::string& uri, + int rate, + unsigned channels, + unsigned verbosity, + std::string& gain, + std::string& cache, + SampleQueue<uint8_t>& queue) : + VLCInput(uri, rate, channels, verbosity, gain, cache), + m_fault(false), + m_running(false), + m_queue(queue) {} + + ~VLCInputThreaded() + { + if (m_running) { + m_running = false; + m_thread.join(); + } + } + + /* Start the libVLC thread that fills the queue */ + virtual void start(); + + bool fault_detected() { return m_fault; }; + + private: + VLCInputThreaded(const VLCInputThreaded& other) = delete; + VLCInputThreaded& operator=(const VLCInputThreaded& other) = delete; + + void process(); + + std::atomic<bool> m_fault; + std::atomic<bool> m_running; + std::thread m_thread; + SampleQueue<uint8_t>& m_queue; + +}; + #endif // HAVE_VLC #endif |