summaryrefslogtreecommitdiff
path: root/src/input/BufferingInputStream.cxx
diff options
context:
space:
mode:
authorMax Kellermann <max@musicpd.org>2019-05-08 18:39:00 +0200
committerMax Kellermann <max@musicpd.org>2019-05-31 17:49:52 +0200
commit5d74b5cee1c11e7035ba99fa23d724175203319c (patch)
treeed1fa91f3807bca59b2064ea288ba436d1791cfd /src/input/BufferingInputStream.cxx
parente8a0ce643a5e00e768f31387000cdddb2a93cb44 (diff)
input/cache: first draft of the file cache
Diffstat (limited to 'src/input/BufferingInputStream.cxx')
-rw-r--r--src/input/BufferingInputStream.cxx12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/input/BufferingInputStream.cxx b/src/input/BufferingInputStream.cxx
index 8888f597c..9bdb91b49 100644
--- a/src/input/BufferingInputStream.cxx
+++ b/src/input/BufferingInputStream.cxx
@@ -152,6 +152,18 @@ BufferingInputStream::RunThreadLocked(std::unique_lock<Mutex> &lock)
continue;
}
+ /* enforce an upper limit for each
+ InputStream::Read() call; this is necessary
+ for plugins which are unable to do partial
+ reads, e.g. when reading local files, the
+ read() system call will not return until
+ all requested bytes have been read from the
+ hard disk, instead of returning when "some"
+ data has been read */
+ constexpr size_t MAX_READ = 64 * 1024;
+ if (w.size > MAX_READ)
+ w.size = MAX_READ;
+
size_t nbytes = input->Read(lock, w.data, w.size);
buffer.Commit(read_offset, read_offset + nbytes);