summaryrefslogtreecommitdiffstats
path: root/src/SampleQueue.h
diff options
context:
space:
mode:
authorMaPePeR <MaPePeR@users.noreply.github.com>2018-06-01 14:10:54 +0200
committerMatthias P. Braendli <matthias.braendli@mpb.li>2018-06-04 14:21:19 +0200
commitee29f6dbd130f26ed51b7a94b34790ba4c039089 (patch)
tree8d46ae6451f1f61dee3b78af2096b6e34365a93a /src/SampleQueue.h
parent510b1edfd400752f91957e058fd6e009ed694d92 (diff)
downloadODR-AudioEnc-ee29f6dbd130f26ed51b7a94b34790ba4c039089.tar.gz
ODR-AudioEnc-ee29f6dbd130f26ed51b7a94b34790ba4c039089.tar.bz2
ODR-AudioEnc-ee29f6dbd130f26ed51b7a94b34790ba4c039089.zip
Check if overruns occured even when drift compensation is not turned on
(cherry picked from commit 15610351b76113f1026e4ad40ec7ba9926d09498)
Diffstat (limited to 'src/SampleQueue.h')
-rw-r--r--src/SampleQueue.h9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/SampleQueue.h b/src/SampleQueue.h
index dd01986..646f3dd 100644
--- a/src/SampleQueue.h
+++ b/src/SampleQueue.h
@@ -120,10 +120,12 @@ public:
/*! Wait until len elements in the queue are available,
* and then fill the buf. If the timeout_ms (expressed in milliseconds
* expires), fill the available number of elements.
+ * Also update the overrun variable with the information
+ * of how many overruns we saw since the last pop.
*
* \return the number of elemets written into buf
*/
- size_t pop_wait(T* buf, size_t len, int timeout_ms)
+ size_t pop_wait(T* buf, size_t len, int timeout_ms, size_t* overruns = NULL)
{
assert(len % (m_channels * m_bytes_per_sample) == 0);
@@ -132,6 +134,11 @@ public:
#endif
std::unique_lock<std::mutex> lock(m_mutex);
+ if (overruns) {
+ *overruns = m_overruns;
+ m_overruns = 0;
+ }
+
auto time_start = std::chrono::steady_clock::now();
const auto timeout = std::chrono::milliseconds(timeout_ms);