aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorarnova <arnova@void.org>2014-11-16 15:35:20 +0100
committerarnova <arnova@void.org>2014-11-23 09:51:29 +0100
commitc82ba33666fa9e50b5ffa3d16147c4ba974182b3 (patch)
treeffc85e4b8120001461f0ae20a701fcefbb163cb9
parent18fa9640bb5d637376165a6c122d648138434b98 (diff)
fixed: Calling WaitForData with a large minimum could cause it to block the max. timeout
-rw-r--r--xbmc/filesystem/CircularCache.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/xbmc/filesystem/CircularCache.cpp b/xbmc/filesystem/CircularCache.cpp
index e78efce283..5596b37936 100644
--- a/xbmc/filesystem/CircularCache.cpp
+++ b/xbmc/filesystem/CircularCache.cpp
@@ -178,6 +178,10 @@ int CCircularCache::ReadFromCache(char *buf, size_t len)
return len;
}
+/* Wait "millis" milliseconds for "minimum" amount of data to come in.
+ * Note that caller needs to make sure there's sufficient space in the forward
+ * buffer for "minimum" bytes else we may block the full timeout time
+ */
int64_t CCircularCache::WaitForData(unsigned int minumum, unsigned int millis)
{
CSingleLock lock(m_sync);
@@ -209,6 +213,11 @@ int64_t CCircularCache::Seek(int64_t pos)
// we try to avoid a (heavy) seek on the source
if (pos >= m_end && pos < m_end + 100000)
{
+ /* Make everything in the cache (back & forward) back-cache, to make sure
+ * there's sufficient forward space. Increasing it with only 100000 may not be
+ * sufficient due to variable filesystem chunksize
+ */
+ m_cur = m_end;
lock.Leave();
WaitForData((size_t)(pos - m_cur), 5000);
lock.Enter();