summaryrefslogtreecommitdiffstats
path: root/src/VLCInput.cpp
diff options
context:
space:
mode:
authorMatthias P. Braendli <matthias.braendli@mpb.li>2016-01-10 17:02:50 +0100
committerMatthias P. Braendli <matthias.braendli@mpb.li>2016-01-10 17:18:45 +0100
commite4821033a325b748c1c69848554b349c76ba6f59 (patch)
tree5626e72fc145e23ea5766984720c5adf643730d5 /src/VLCInput.cpp
parentc36c65f341429d8b6412be23205f6f9d1b0c864c (diff)
downloadODR-AudioEnc-e4821033a325b748c1c69848554b349c76ba6f59.tar.gz
ODR-AudioEnc-e4821033a325b748c1c69848554b349c76ba6f59.tar.bz2
ODR-AudioEnc-e4821033a325b748c1c69848554b349c76ba6f59.zip
Add VLC variant with drift compensation
Diffstat (limited to 'src/VLCInput.cpp')
-rw-r--r--src/VLCInput.cpp34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/VLCInput.cpp b/src/VLCInput.cpp
index 7f6aae8..890de01 100644
--- a/src/VLCInput.cpp
+++ b/src/VLCInput.cpp
@@ -354,6 +354,40 @@ void VLCInput::write_icy_text(const std::string& filename)
}
}
+
+// ==================== VLCInputThreaded ====================
+
+void VLCInputThreaded::start()
+{
+ if (m_fault) {
+ fprintf(stderr, "Cannot start VLC input. Fault detected previsouly!\n");
+ }
+ else {
+ m_running = true;
+ m_thread = std::thread(&VLCInputThreaded::process, this);
+ }
+}
+
+void VLCInputThreaded::process()
+{
+ uint8_t samplebuf[NUM_SAMPLES_PER_CALL * BYTES_PER_SAMPLE * m_channels];
+ while (m_running) {
+ ssize_t n = m_read(samplebuf, NUM_SAMPLES_PER_CALL);
+
+ if (n < 0) {
+ m_running = false;
+ m_fault = true;
+ break;
+ }
+
+ m_queue.push(samplebuf, BYTES_PER_SAMPLE*m_channels*n);
+ }
+}
+
+
+
+
+
/* VLC up to version 2.1.0 used a different callback function signature.
* VLC 2.2.0 uses size_t
*