tag/Id3Load: split tag_id3_read()
This commit is contained in:
		| @@ -60,13 +60,12 @@ get_id3v2_footer_size(FILE *stream, long offset, int whence) | |||||||
| } | } | ||||||
|  |  | ||||||
| static UniqueId3Tag | 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]; | 	id3_byte_t query_buffer[ID3_TAG_QUERYSIZE]; | ||||||
| 	size_t query_buffer_size = fill_buffer(query_buffer, ID3_TAG_QUERYSIZE, | 	size_t query_buffer_size = fread(query_buffer, 1, sizeof(query_buffer), | ||||||
| 					       stream, offset, whence); | 					 file); | ||||||
| 	if (query_buffer_size <= 0) | 	if (query_buffer_size == 0) | ||||||
| 		return nullptr; | 		return nullptr; | ||||||
|  |  | ||||||
| 	/* Look for a tag header */ | 	/* Look for a tag header */ | ||||||
| @@ -87,13 +86,22 @@ tag_id3_read(FILE *stream, long offset, int whence) | |||||||
|  |  | ||||||
| 	/* now read the remaining bytes */ | 	/* now read the remaining bytes */ | ||||||
| 	const size_t remaining = tag_size - query_buffer_size; | 	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) | 	if (nbytes != remaining) | ||||||
| 		return nullptr; | 		return nullptr; | ||||||
|  |  | ||||||
| 	return UniqueId3Tag(id3_tag_parse(tag_buffer.get(), tag_size)); | 	return UniqueId3Tag(id3_tag_parse(tag_buffer.get(), tag_size)); | ||||||
| } | } | ||||||
|  |  | ||||||
|  | static UniqueId3Tag | ||||||
|  | tag_id3_read(FILE *file, long offset, int whence) | ||||||
|  | { | ||||||
|  | 	if (fseek(file, offset, whence) != 0) | ||||||
|  | 		return 0; | ||||||
|  |  | ||||||
|  | 	return ReadId3Tag(file); | ||||||
|  | } | ||||||
|  |  | ||||||
| static UniqueId3Tag | static UniqueId3Tag | ||||||
| tag_id3_find_from_beginning(FILE *stream) | tag_id3_find_from_beginning(FILE *stream) | ||||||
| { | { | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Max Kellermann
					Max Kellermann