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
84fe3bfa
Commit
84fe3bfa
authored
Feb 19, 2016
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tag/Id3Load: don't seek twice in tag_id3_read()
Copy the query buffer to the allocated buffer, and read only the remaining data.
parent
2ef8403b
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
4 deletions
+13
-4
Id3Load.cxx
src/tag/Id3Load.cxx
+13
-4
No files found.
src/tag/Id3Load.cxx
View file @
84fe3bfa
...
...
@@ -30,6 +30,8 @@
#include <id3tag.h>
#include <algorithm>
#include <stdio.h>
static
constexpr
Domain
id3_domain
(
"id3"
);
...
...
@@ -77,12 +79,19 @@ tag_id3_read(FILE *stream, long offset, int whence)
return
UniqueId3Tag
(
id3_tag_parse
(
query_buffer
,
tag_size
));
std
::
unique_ptr
<
id3_byte_t
[]
>
tag_buffer
(
new
id3_byte_t
[
tag_size
]);
int
tag_buffer_size
=
fill_buffer
(
tag_buffer
.
get
(),
tag_size
,
stream
,
offset
,
whence
);
if
(
tag_buffer_size
<
tag_size
)
/* copy the start of the tag we already have to the allocated
buffer */
id3_byte_t
*
end
=
std
::
copy_n
(
query_buffer
,
query_buffer_size
,
tag_buffer
.
get
());
/* now read the remaining bytes */
const
size_t
remaining
=
tag_size
-
query_buffer_size
;
const
size_t
nbytes
=
fread
(
end
,
1
,
remaining
,
stream
);
if
(
nbytes
!=
remaining
)
return
nullptr
;
return
UniqueId3Tag
(
id3_tag_parse
(
tag_buffer
.
get
(),
tag_
buffer_
size
));
return
UniqueId3Tag
(
id3_tag_parse
(
tag_buffer
.
get
(),
tag_size
));
}
static
UniqueId3Tag
...
...
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