From 3330e5d76e1c224cb5c7b43e517bf869d1454d6d Mon Sep 17 00:00:00 2001 From: "Matthias P. Braendli" Date: Mon, 5 Feb 2018 16:26:23 +0100 Subject: Fix downmixing for VLC --- src/VLCInput.cpp | 9 +++------ src/VLCInput.h | 1 - 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/src/VLCInput.cpp b/src/VLCInput.cpp index 5912509..6519d49 100644 --- a/src/VLCInput.cpp +++ b/src/VLCInput.cpp @@ -332,16 +332,13 @@ void VLCInput::postRender_cb(unsigned int channels, size_t size) assert(size == m_current_buf.size() * sizeof(float)); - if (channels == getChannels()) { + if (channels == m_channels) { size_t queue_size = m_queue.size(); m_queue.resize(m_queue.size() + m_current_buf.size()); std::copy(m_current_buf.begin(), m_current_buf.end(), m_queue.begin() + queue_size); } - else if (channels == 2 and getChannels() == 1) { - size_t queue_size = m_queue.size(); - m_queue.resize(m_queue.size() + m_current_buf.size()); - + else if (channels == 2 and m_channels == 1) { // Downmix to 1 channel for (size_t i = 0; i+1 < m_current_buf.size(); i += 2) { m_queue.push_back(0.5f * (m_current_buf[i] + m_current_buf[i+1])); @@ -349,7 +346,7 @@ void VLCInput::postRender_cb(unsigned int channels, size_t size) } else { fprintf(stderr, "Got invalid number of channels back from VLC! " - "requested: %d, got %d\n", getChannels(), channels); + "requested: %d, got %d\n", m_channels, channels); m_running = false; m_fault = true; } diff --git a/src/VLCInput.h b/src/VLCInput.h index c727fdf..99ce01d 100644 --- a/src/VLCInput.h +++ b/src/VLCInput.h @@ -134,7 +134,6 @@ class VLCInput : public InputInterface int getRate() { return m_rate; } - int getChannels() { return m_channels; } virtual bool fault_detected(void) const override { return m_fault; }; -- cgit v1.2.3