diff options
-rw-r--r-- | lib/rbcodec/metadata/mp3data.c | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/lib/rbcodec/metadata/mp3data.c b/lib/rbcodec/metadata/mp3data.c index 83605126d6..f30e954e93 100644 --- a/lib/rbcodec/metadata/mp3data.c +++ b/lib/rbcodec/metadata/mp3data.c | |||
@@ -260,26 +260,29 @@ static unsigned long __find_next_frame(int fd, long *offset, long max_offset, | |||
260 | * seek to this byte position and check if there is another | 260 | * seek to this byte position and check if there is another |
261 | * valid MPEG frame header of the same type. */ | 261 | * valid MPEG frame header of the same type. */ |
262 | struct mp3info info; | 262 | struct mp3info info; |
263 | 263 | ||
264 | /* Gather frame size from given header and seek to next | 264 | /* Gather frame size from given header and seek to next |
265 | * frame header. */ | 265 | * frame header. */ |
266 | mp3headerinfo(&info, header); | 266 | if (!mp3headerinfo(&info, header)) continue; |
267 | lseek(fd, info.frame_size-4, SEEK_CUR); | 267 | lseek(fd, info.frame_size-4, SEEK_CUR); |
268 | 268 | ||
269 | /* Read possible next frame header and seek back to last frame | 269 | /* Read possible next frame header and seek back to last frame |
270 | * headers byte position. */ | 270 | * headers byte position. */ |
271 | reference_header = 0; | 271 | reference_header = 0; |
272 | read_uint32be_mp3data(fd, &reference_header); | 272 | read_uint32be_mp3data(fd, &reference_header); |
273 | // | 273 | |
274 | lseek(fd, -info.frame_size, SEEK_CUR); | 274 | /* If the current header is of the same type as the previous |
275 | 275 | * header we are finished. Rewind to frame data start. */ | |
276 | /* If the current header is of the same type as the previous | 276 | if (headers_have_same_type(header, reference_header)) { |
277 | * header we are finished. */ | 277 | lseek(fd, -info.frame_size, SEEK_CUR); |
278 | if (headers_have_same_type(header, reference_header)) | ||
279 | break; | 278 | break; |
279 | } | ||
280 | /* Otherwise keep going. Rewind to to start of "next" frame. */ | ||
281 | lseek(fd, -4, SEEK_CUR); | ||
282 | pos += info.frame_size - 4; | ||
280 | } | 283 | } |
281 | } | 284 | } |
282 | 285 | ||
283 | } while (true); | 286 | } while (true); |
284 | 287 | ||
285 | *offset = pos - 4; | 288 | *offset = pos - 4; |
@@ -511,8 +514,8 @@ static int get_next_header_info(int fd, long *bytecount, struct mp3info *info, | |||
511 | { | 514 | { |
512 | long tmp; | 515 | long tmp; |
513 | unsigned long header = 0; | 516 | unsigned long header = 0; |
514 | 517 | ||
515 | header = __find_next_frame(fd, &tmp, 0x20000, 0, fileread, single_header); | 518 | header = __find_next_frame(fd, &tmp, 0x100000, 0, fileread, single_header); |
516 | if(header == 0) | 519 | if(header == 0) |
517 | return -1; | 520 | return -1; |
518 | 521 | ||