summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias P. Braendli <matthias.braendli@mpb.li>2015-03-12 19:04:14 +0100
committerMatthias P. Braendli <matthias.braendli@mpb.li>2015-03-12 19:04:14 +0100
commita3d8608ae73e7ff1ab4fccedb24455597275d544 (patch)
tree67d58c3e28e2dc78a7c473633048bd521b93b03f
parentb949fc3fec017fefcbf1a11bfb713f11487c4162 (diff)
downloadODR-AudioEnc-a3d8608ae73e7ff1ab4fccedb24455597275d544.tar.gz
ODR-AudioEnc-a3d8608ae73e7ff1ab4fccedb24455597275d544.tar.bz2
ODR-AudioEnc-a3d8608ae73e7ff1ab4fccedb24455597275d544.zip
Add limit on maximal buffer for VLC
-rw-r--r--src/VLCInput.cpp16
1 files changed, 13 insertions, 3 deletions
diff --git a/src/VLCInput.cpp b/src/VLCInput.cpp
index 555b1e1..6b7a4bb 100644
--- a/src/VLCInput.cpp
+++ b/src/VLCInput.cpp
@@ -111,10 +111,20 @@ int VLCInput::prepare()
void VLCInput::preRender(uint8_t** pp_pcm_buffer, size_t size)
{
- boost::mutex::scoped_lock lock(m_queue_mutex);
+ const size_t max_length = 20 * size;
- m_current_buf.resize(size);
- *pp_pcm_buffer = &m_current_buf[0];
+ for (;;) {
+ boost::mutex::scoped_lock lock(m_queue_mutex);
+
+ if (m_queue.size() < max_length) {
+ m_current_buf.resize(size);
+ *pp_pcm_buffer = &m_current_buf[0];
+ return;
+ }
+
+ lock.unlock();
+ boost::this_thread::sleep(boost::posix_time::milliseconds(1));
+ }
}
void VLCInput::postRender(uint8_t* p_pcm_buffer, size_t size)