|
From: Lasse Kärkkäi. <tr...@us...> - 2011-02-08 14:31:21
|
Module: editor
Branch: master
Commit: f6e5363fa39914fcce35f802580f7e7c8a109e12
Author: Lasse Karkkainen <tro...@tr...>
Date: Tue Feb 8 15:30:41 2011 +0100
Fix a bug in AudioQueue ring buffer.
---
ffmpeg.hh | 12 ++++++------
1 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/ffmpeg.hh b/ffmpeg.hh
index 8814503..003ff29 100644
--- a/ffmpeg.hh
+++ b/ffmpeg.hh
@@ -45,14 +45,14 @@ public:
da::sample_t* outptr = &out[outsz];
Ring::iterator b = m_ring.begin() + m_position,
e = m_ring.begin() + (m_position + m_size) % m_ring.size();
- if (e < b) {
- // Two parts copied separately
+ if (e <= b) {
+ // Copy the first part
std::copy(b, m_ring.end(), outptr);
- std::copy(m_ring.begin(), e, outptr);
- } else {
- // All in one part
- std::copy(b, e, outptr);
+ outptr += m_ring.end() - b;
+ b = m_ring.begin();
}
+ // Copy the only/last part
+ std::copy(b, e, outptr);
m_size = 0;
m_needSpace.wakeOne();
return true;
|