command/file: "albumart" tries to send larger chunks if available
If we only receive very little data from the InputStream, try a second Read() call to get more data. This works around tiny reads at input buffer boundaries with the io_uring input plugin. These tiny reads are inefficient, and we can afford to wait one more low-level I/O iteration to finish (but not more). Closes https://github.com/MusicPlayerDaemon/MPD/issues/2186
This commit is contained in:
2
NEWS
2
NEWS
@@ -1,4 +1,6 @@
|
|||||||
ver 0.23.17 (not yet released)
|
ver 0.23.17 (not yet released)
|
||||||
|
* protocol
|
||||||
|
- "albumart" tries to send larger chunks if available
|
||||||
* storage
|
* storage
|
||||||
- nfs: require libnfs 4.0 or later
|
- nfs: require libnfs 4.0 or later
|
||||||
* database
|
* database
|
||||||
|
@@ -215,7 +215,20 @@ read_stream_art(Response &r, const std::string_view art_directory,
|
|||||||
if (buffer_size > 0) {
|
if (buffer_size > 0) {
|
||||||
std::unique_lock<Mutex> lock(is->mutex);
|
std::unique_lock<Mutex> lock(is->mutex);
|
||||||
is->Seek(lock, offset);
|
is->Seek(lock, offset);
|
||||||
|
|
||||||
|
const bool was_ready = is->IsReady();
|
||||||
|
|
||||||
read_size = is->Read(lock, buffer.get(), buffer_size);
|
read_size = is->Read(lock, buffer.get(), buffer_size);
|
||||||
|
|
||||||
|
if (was_ready && read_size < buffer_size / 2)
|
||||||
|
/* the InputStream was ready before, but we
|
||||||
|
got only very little data; probably just
|
||||||
|
some data left in the buffer without doing
|
||||||
|
any I/O; let's wait for the next low-level
|
||||||
|
read to complete to get more data for the
|
||||||
|
client */
|
||||||
|
read_size += is->Read(lock, buffer.get() + read_size,
|
||||||
|
buffer_size - read_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
r.Fmt("size: {}\n", art_file_size);
|
r.Fmt("size: {}\n", art_file_size);
|
||||||
|
Reference in New Issue
Block a user