aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2014-12-23 20:34:45 +0100
committerMax Kellermann <max@duempel.org>2014-12-23 20:34:45 +0100
commit43da4c0ecaf23ebb7b282bdfe3b5c6bfc3ab6c41 (patch)
tree55955ac3976c8d781959bf6038c36f34a26e8e54 /src
parentb9c7771830dbecd7278ae6c883b4590f909cb881 (diff)
downloadmpd-43da4c0ecaf23ebb7b282bdfe3b5c6bfc3ab6c41.tar.gz
mpd-43da4c0ecaf23ebb7b282bdfe3b5c6bfc3ab6c41.tar.xz
mpd-43da4c0ecaf23ebb7b282bdfe3b5c6bfc3ab6c41.zip
input/mms: limit the mmsx_read() size
Diffstat (limited to 'src')
-rw-r--r--src/input/plugins/MmsInputPlugin.cxx7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/input/plugins/MmsInputPlugin.cxx b/src/input/plugins/MmsInputPlugin.cxx
index 1aed9c662..df291bc84 100644
--- a/src/input/plugins/MmsInputPlugin.cxx
+++ b/src/input/plugins/MmsInputPlugin.cxx
@@ -92,6 +92,13 @@ input_mms_open(const char *url,
size_t
MmsInputStream::ThreadRead(void *ptr, size_t read_size, Error &error)
{
+ /* unfortunately, mmsx_read() blocks until the whole buffer
+ has been filled; to avoid big latencies, limit the size of
+ each chunk we read to a reasonable size */
+ constexpr size_t MAX_CHUNK = 16384;
+ if (read_size > MAX_CHUNK)
+ read_size = MAX_CHUNK;
+
int nbytes = mmsx_read(nullptr, mms, (char *)ptr, read_size);
if (nbytes <= 0) {
if (nbytes < 0)