summaryrefslogtreecommitdiff
path: root/firmware/mpeg.c
diff options
context:
space:
mode:
authorLinus Nielsen Feltzing <linus@haxx.se>2003-03-10 18:25:40 +0000
committerLinus Nielsen Feltzing <linus@haxx.se>2003-03-10 18:25:40 +0000
commit2c07e78efc0e8ab7150eef7ae92af32b2389146a (patch)
tree3c599a72a1ad318f3deaaf6d02334c4f0c936a0f /firmware/mpeg.c
parent6475aa0c85fcca7a37a7aa4316173270fcb6d038 (diff)
Don't accidentally add Xing headers to CBR files
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@3419 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/mpeg.c')
-rw-r--r--firmware/mpeg.c67
1 files changed, 37 insertions, 30 deletions
diff --git a/firmware/mpeg.c b/firmware/mpeg.c
index 13c4b01b8a..9528ede0ec 100644
--- a/firmware/mpeg.c
+++ b/firmware/mpeg.c
@@ -3030,42 +3030,49 @@ int mpeg_create_xing_header(char *filename, void (*progressfunc)(int))
progressfunc(0);
num_frames = count_mp3_frames(fd, entry.first_frame_offset,
- flen,
- progressfunc);
+ flen, progressfunc);
- create_xing_header(fd, entry.first_frame_offset,
- flen, xingbuf, num_frames, progressfunc, true);
-
- /* Try to fit the Xing header first in the stream. Replace the existing
- Xing header if there is one, else see if there is room between the
- ID3 tag and the first MP3 frame. */
- if(entry.vbr_header_pos)
- {
- /* Reuse existing Xing header */
- fpos = entry.vbr_header_pos;
-
- DEBUGF("Reusing Xing header at %d\n", fpos);
- }
- else
+ if(num_frames)
{
- /* Any room between ID3 tag and first MP3 frame? */
- if(entry.first_frame_offset - entry.id3v2len > 417)
+ create_xing_header(fd, entry.first_frame_offset,
+ flen, xingbuf, num_frames, progressfunc, true);
+
+ /* Try to fit the Xing header first in the stream. Replace the existing
+ Xing header if there is one, else see if there is room between the
+ ID3 tag and the first MP3 frame. */
+ if(entry.vbr_header_pos)
{
- fpos = entry.first_frame_offset - 417;
+ /* Reuse existing Xing header */
+ fpos = entry.vbr_header_pos;
+
+ DEBUGF("Reusing Xing header at %d\n", fpos);
}
else
{
- close(fd);
- return -3;
+ /* Any room between ID3 tag and first MP3 frame? */
+ if(entry.first_frame_offset - entry.id3v2len > 417)
+ {
+ fpos = entry.first_frame_offset - 417;
+ }
+ else
+ {
+ close(fd);
+ return -3;
+ }
}
+
+ lseek(fd, fpos, SEEK_SET);
+ write(fd, xingbuf, 417);
+ close(fd);
+
+ if(progressfunc)
+ progressfunc(100);
+ return 0;
+ }
+ else
+ {
+ /* Not a VBR file */
+ DEBUGF("Not a VBR file\n");
+ return -9;
}
-
- lseek(fd, fpos, SEEK_SET);
- write(fd, xingbuf, 417);
- close(fd);
-
- if(progressfunc)
- progressfunc(100);
-
- return 0;
}