From 35977fc2e90a7bf7aedd1c0be13f14289dd061df Mon Sep 17 00:00:00 2001 From: "Matthias P. Braendli" Date: Mon, 30 Mar 2015 18:37:43 +0200 Subject: VLC: change callback usage --- src/VLCInput.cpp | 24 ++++++++++-------------- src/VLCInput.h | 7 ++----- 2 files changed, 12 insertions(+), 19 deletions(-) diff --git a/src/VLCInput.cpp b/src/VLCInput.cpp index c4c0413..7c782b0 100644 --- a/src/VLCInput.cpp +++ b/src/VLCInput.cpp @@ -60,7 +60,10 @@ void handleStream( assert(rate == in->getRate()); assert(bits_per_sample == 8*BYTES_PER_SAMPLE); - in->postRender_cb(p_pcm_buffer, size); + // This assumes VLC always gives back the full + // buffer it asked for. According to VLC code + // smem.c for v2.2.0 this holds. + in->postRender_cb(); } // VLC Exit callback @@ -159,22 +162,14 @@ void VLCInput::cleanup() } } -void VLCInput::postRender_cb(uint8_t* p_pcm_buffer, size_t size) +void VLCInput::postRender_cb() { boost::mutex::scoped_lock lock(m_queue_mutex); - if (m_current_buf.size() == size) { - size_t queue_size = m_queue.size(); - m_queue.resize(m_queue.size() + size); - std::copy(m_current_buf.begin(), m_current_buf.end(), - m_queue.begin() + queue_size); - } - else { - fprintf(stderr, - "Received buffer size is not equal allocated " - "buffer size: %zu vs %zu\n", - m_current_buf.size(), size); - } + 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); } ssize_t VLCInput::m_read(uint8_t* buf, size_t length) @@ -199,6 +194,7 @@ ssize_t VLCInput::m_read(uint8_t* buf, size_t length) if (!(st == libvlc_Opening || st == libvlc_Buffering || st == libvlc_Playing) ) { + fprintf(stderr, "VLC state is %d\n", st); err = -1; break; } diff --git a/src/VLCInput.h b/src/VLCInput.h index e4a0557..f97b9d9 100644 --- a/src/VLCInput.h +++ b/src/VLCInput.h @@ -74,12 +74,9 @@ class VLCInput uint8_t** pp_pcm_buffer, size_t size); - /* Receive a buffer with audio samples - * from VLC + /* Notification from VLC that the buffer is now filled */ - void postRender_cb( - uint8_t* p_pcm_buffer, - size_t size); + void postRender_cb(); int getRate() { return m_rate; } -- cgit v1.2.3