tag/Id3Load: optimized ID3v1 loader
Use a 128 byte buffer instead of reading 10 bytes first and then 118.
This commit is contained in:
parent
57da5c0841
commit
c682d087d9
@ -95,6 +95,17 @@ ReadId3Tag(FILE *file)
|
|||||||
return UniqueId3Tag(id3_tag_parse(tag_buffer.get(), tag_size));
|
return UniqueId3Tag(id3_tag_parse(tag_buffer.get(), tag_size));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static UniqueId3Tag
|
||||||
|
ReadId3v1Tag(FILE *file)
|
||||||
|
{
|
||||||
|
id3_byte_t buffer[ID3V1_SIZE];
|
||||||
|
|
||||||
|
if (fread(buffer, 1, ID3V1_SIZE, file) != ID3V1_SIZE)
|
||||||
|
return nullptr;
|
||||||
|
|
||||||
|
return UniqueId3Tag(id3_tag_parse(buffer, ID3V1_SIZE));
|
||||||
|
}
|
||||||
|
|
||||||
static UniqueId3Tag
|
static UniqueId3Tag
|
||||||
tag_id3_read(FILE *file, long offset, int whence)
|
tag_id3_read(FILE *file, long offset, int whence)
|
||||||
{
|
{
|
||||||
@ -141,7 +152,10 @@ tag_id3_find_from_end(FILE *stream)
|
|||||||
off_t offset = -(off_t)ID3V1_SIZE;
|
off_t offset = -(off_t)ID3V1_SIZE;
|
||||||
|
|
||||||
/* Get an id3v1 tag from the end of file for later use */
|
/* Get an id3v1 tag from the end of file for later use */
|
||||||
auto v1tag = tag_id3_read(stream, offset, SEEK_END);
|
if (fseek(stream, offset, SEEK_END) != 0)
|
||||||
|
return nullptr;
|
||||||
|
|
||||||
|
auto v1tag = ReadId3v1Tag(stream);
|
||||||
if (!v1tag)
|
if (!v1tag)
|
||||||
offset = 0;
|
offset = 0;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user