mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-12-11 06:05:21 -05:00
Prevent unaligned memory accesses whilst reading seektable - fixes FLAC playback on iPod
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@8477 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
281403a4d8
commit
b0302f0cbb
1 changed files with 13 additions and 7 deletions
|
|
@ -86,7 +86,6 @@ static bool flac_init(FLACContext* fc, int first_frame_offset)
|
||||||
int endofmetadata=0;
|
int endofmetadata=0;
|
||||||
int blocklength;
|
int blocklength;
|
||||||
int n;
|
int n;
|
||||||
uint32_t* p;
|
|
||||||
|
|
||||||
ci->memset(fc,0,sizeof(FLACContext));
|
ci->memset(fc,0,sizeof(FLACContext));
|
||||||
nseekpoints=0;
|
nseekpoints=0;
|
||||||
|
|
@ -152,12 +151,19 @@ static bool flac_init(FLACContext* fc, int first_frame_offset)
|
||||||
if (n < 18) return false;
|
if (n < 18) return false;
|
||||||
blocklength-=n;
|
blocklength-=n;
|
||||||
|
|
||||||
p=(uint32_t*)buf;
|
seekpoint_hi=(buf[0] << 24) | (buf[1] << 16) |
|
||||||
seekpoint_hi=betoh32(*(p++));
|
(buf[2] << 8) | buf[3];
|
||||||
seekpoint_lo=betoh32(*(p++));
|
seekpoint_lo=(buf[4] << 24) | (buf[5] << 16) |
|
||||||
offset_hi=betoh32(*(p++));
|
(buf[6] << 8) | buf[7];
|
||||||
offset_lo=betoh32(*(p++));
|
offset_hi=(buf[8] << 24) | (buf[9] << 16) |
|
||||||
|
(buf[10] << 8) | buf[11];
|
||||||
|
offset_lo=(buf[12] << 24) | (buf[13] << 16) |
|
||||||
|
(buf[14] << 8) | buf[15];
|
||||||
|
|
||||||
|
/* The final two bytes contain the number of samples in the
|
||||||
|
target frame - but we don't care about that. */
|
||||||
|
|
||||||
|
/* Only store seekpoints where the high 32 bits are zero */
|
||||||
if ((seekpoint_hi == 0) && (seekpoint_lo != 0xffffffff) &&
|
if ((seekpoint_hi == 0) && (seekpoint_lo != 0xffffffff) &&
|
||||||
(offset_hi == 0)) {
|
(offset_hi == 0)) {
|
||||||
seekpoints[nseekpoints].sample=seekpoint_lo;
|
seekpoints[nseekpoints].sample=seekpoint_lo;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue