forked from len0rd/rockbox
(1) Bugfix: create_xing_header() now returns 0 in case of an invalid header template, i.e. when mp3headerinfo() returns false. It used to return a random number, causing all sorts of problems. This was the cause for the end of a recording (still in the buffer) occasionally overwriting the beginning. (2) Some code cleanup.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@6557 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
f40175c8dc
commit
509117db90
1 changed files with 14 additions and 19 deletions
|
|
@ -678,11 +678,20 @@ int create_xing_header(int fd, int startpos, int filesize,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Use the template header and create a new one.
|
||||||
|
We ignore the Protection bit even if the rest of the stream is
|
||||||
|
protected. (fixme?) */
|
||||||
|
header = xing_header_template & ~(BITRATE_MASK | PROTECTION_MASK);
|
||||||
|
header |= 8 << 12; /* This gives us plenty of space, at least 192 bytes */
|
||||||
|
|
||||||
|
if (!mp3headerinfo(&info, header))
|
||||||
|
return 0; /* invalid header */
|
||||||
|
|
||||||
/* Clear the frame */
|
/* Clear the frame */
|
||||||
memset(buf, 0, 1500);
|
memset(buf, 0, 1500);
|
||||||
|
|
||||||
/* Use the template header and create a new one */
|
/* Write the header to the buffer */
|
||||||
mp3headerinfo(&info, xing_header_template);
|
long2bytes(buf, header);
|
||||||
|
|
||||||
/* calculate position of VBR header */
|
/* calculate position of VBR header */
|
||||||
if ( info.version == MPEG_VERSION1 ) {
|
if ( info.version == MPEG_VERSION1 ) {
|
||||||
|
|
@ -698,22 +707,8 @@ int create_xing_header(int fd, int startpos, int filesize,
|
||||||
index = 21;
|
index = 21;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* We ignore the Protection bit even if the rest of the stream is
|
|
||||||
protected. (fixme?) */
|
|
||||||
header = xing_header_template & ~(BITRATE_MASK | PROTECTION_MASK);
|
|
||||||
header |= 8 << 12; /* This gives us plenty of space, at least 192 bytes */
|
|
||||||
|
|
||||||
/* Write the header to the buffer */
|
|
||||||
long2bytes(buf, header);
|
|
||||||
|
|
||||||
/* Now get the length of the newly created frame */
|
|
||||||
mp3headerinfo(&info, header);
|
|
||||||
|
|
||||||
/* Create the Xing data */
|
/* Create the Xing data */
|
||||||
buf[index] = 'X';
|
memcpy(&buf[index], "Xing", 4);
|
||||||
buf[index+1] = 'i';
|
|
||||||
buf[index+2] = 'n';
|
|
||||||
buf[index+3] = 'g';
|
|
||||||
long2bytes(&buf[index+4], ((num_frames?VBR_FRAMES_FLAG:0) |
|
long2bytes(&buf[index+4], ((num_frames?VBR_FRAMES_FLAG:0) |
|
||||||
(filesize?VBR_BYTES_FLAG:0) |
|
(filesize?VBR_BYTES_FLAG:0) |
|
||||||
(generate_toc?VBR_TOC_FLAG:0)));
|
(generate_toc?VBR_TOC_FLAG:0)));
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue