Commit 054e9eca authored by Max Kellermann's avatar Max Kellermann

tag/Id3Load: split tag_id3_read()

parent 84fe3bfa
......@@ -60,13 +60,12 @@ get_id3v2_footer_size(FILE *stream, long offset, int whence)
}
static UniqueId3Tag
tag_id3_read(FILE *stream, long offset, int whence)
ReadId3Tag(FILE *file)
{
/* It's ok if we get less than we asked for */
id3_byte_t query_buffer[ID3_TAG_QUERYSIZE];
size_t query_buffer_size = fill_buffer(query_buffer, ID3_TAG_QUERYSIZE,
stream, offset, whence);
if (query_buffer_size <= 0)
size_t query_buffer_size = fread(query_buffer, 1, sizeof(query_buffer),
file);
if (query_buffer_size == 0)
return nullptr;
/* Look for a tag header */
......@@ -87,7 +86,7 @@ tag_id3_read(FILE *stream, long offset, int whence)
/* now read the remaining bytes */
const size_t remaining = tag_size - query_buffer_size;
const size_t nbytes = fread(end, 1, remaining, stream);
const size_t nbytes = fread(end, 1, remaining, file);
if (nbytes != remaining)
return nullptr;
......@@ -95,6 +94,15 @@ tag_id3_read(FILE *stream, long offset, int whence)
}
static UniqueId3Tag
tag_id3_read(FILE *file, long offset, int whence)
{
if (fseek(file, offset, whence) != 0)
return 0;
return ReadId3Tag(file);
}
static UniqueId3Tag
tag_id3_find_from_beginning(FILE *stream)
{
auto tag = tag_id3_read(stream, 0, SEEK_SET);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment