Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
dbb18a40
Commit
dbb18a40
authored
May 18, 2021
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
command/file: cache the last "albumart" file
Closes
https://github.com/MusicPlayerDaemon/MPD/issues/1156
parent
e1e41708
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
21 additions
and
4 deletions
+21
-4
NEWS
NEWS
+1
-0
Client.hxx
src/client/Client.hxx
+8
-0
New.cxx
src/client/New.cxx
+2
-1
FileCommands.cxx
src/command/FileCommands.cxx
+10
-3
No files found.
NEWS
View file @
dbb18a40
ver 0.22.7 (not yet released)
* protocol
- don't use glibc extension to parse time stamps
- optimize the "albumart" command
* input
- curl: send user/password in the first request, save one roundtrip
* decoder
...
...
src/client/Client.hxx
View file @
dbb18a40
...
...
@@ -23,6 +23,7 @@
#include "Message.hxx"
#include "command/CommandResult.hxx"
#include "command/CommandListBuilder.hxx"
#include "input/LastInputStream.hxx"
#include "tag/Mask.hxx"
#include "event/FullyBufferedSocket.hxx"
#include "event/TimerEvent.hxx"
...
...
@@ -90,6 +91,13 @@ public:
*/
size_t
binary_limit
=
8192
;
/**
* This caches the last "albumart" InputStream instance, to
* avoid repeating the search for each chunk requested by this
* client.
*/
LastInputStream
last_album_art
;
private
:
static
constexpr
size_t
MAX_SUBSCRIPTIONS
=
16
;
...
...
src/client/New.cxx
View file @
dbb18a40
...
...
@@ -44,7 +44,8 @@ Client::Client(EventLoop &_loop, Partition &_partition,
partition
(
&
_partition
),
permission
(
_permission
),
uid
(
_uid
),
num
(
_num
)
num
(
_num
),
last_album_art
(
_loop
)
{
timeout_event
.
Schedule
(
client_timeout
);
}
...
...
src/command/FileCommands.cxx
View file @
dbb18a40
...
...
@@ -191,9 +191,16 @@ read_stream_art(Response &r, const char *uri, size_t offset)
{
const
auto
art_directory
=
PathTraitsUTF8
::
GetParent
(
uri
);
Mutex
mutex
;
// TODO: eliminate this const_cast
auto
&
client
=
const_cast
<
Client
&>
(
r
.
GetClient
());
InputStreamPtr
is
=
find_stream_art
(
art_directory
,
mutex
);
/* to avoid repeating the search for each chunk request by the
same client, use the #LastInputStream class to cache the
#InputStream instance */
auto
*
is
=
client
.
last_album_art
.
Open
(
art_directory
,
[](
std
::
string_view
directory
,
Mutex
&
mutex
){
return
find_stream_art
(
directory
,
mutex
);
});
if
(
is
==
nullptr
)
{
r
.
Error
(
ACK_ERROR_NO_EXIST
,
"No file exists"
);
...
...
@@ -219,7 +226,7 @@ read_stream_art(Response &r, const char *uri, size_t offset)
std
::
size_t
read_size
=
0
;
if
(
buffer_size
>
0
)
{
std
::
unique_lock
<
Mutex
>
lock
(
mutex
);
std
::
unique_lock
<
Mutex
>
lock
(
is
->
mutex
);
is
->
Seek
(
lock
,
offset
);
read_size
=
is
->
Read
(
lock
,
buffer
.
get
(),
buffer_size
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment