Mercurial > mplayer.hg
changeset 22140:0cd17afe1d4b
Make sure buffer is aligned so no unaligned access happens.
author | reimar |
---|---|
date | Mon, 05 Feb 2007 19:24:03 +0000 |
parents | 3a3effa718fd |
children | ed81b9614148 |
files | mp3lib/sr1.c |
diffstat | 1 files changed, 8 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/mp3lib/sr1.c Mon Feb 05 19:07:19 2007 +0000 +++ b/mp3lib/sr1.c Mon Feb 05 19:24:03 2007 +0000 @@ -315,7 +315,10 @@ */ LOCAL int read_frame(struct frame *fr){ unsigned long newhead; - unsigned char hbuf[8]; + union { + unsigned char buf[8]; + unsigned long dummy; // for alignment + } hbuf; int skipped,resyncpos; int frames=0; @@ -325,7 +328,7 @@ set_pointer(512); fsizeold=fr->framesize; /* for Layer3 */ - if(!stream_head_read(hbuf,&newhead)) return 0; + if(!stream_head_read(hbuf.buf,&newhead)) return 0; if(!decode_header(fr,newhead)){ // invalid header! try to resync stream! #ifdef DEBUG_RESYNC @@ -333,7 +336,7 @@ #endif retry1: while(!decode_header(fr,newhead)){ - if(!stream_head_shift(hbuf,&newhead)) return 0; + if(!stream_head_shift(hbuf.buf,&newhead)) return 0; } resyncpos=MP3_fpos-4; // found valid header @@ -343,14 +346,14 @@ if(!stream_read_frame_body(fr->framesize)) return 0; // read body set_pointer(512); fsizeold=fr->framesize; /* for Layer3 */ - if(!stream_head_read(hbuf,&newhead)) return 0; + if(!stream_head_read(hbuf.buf,&newhead)) return 0; if(!decode_header(fr,newhead)){ // invalid hdr! go back... #ifdef DEBUG_RESYNC printf("INVALID\n"); #endif // mp3_seek(resyncpos+1); - if(!stream_head_read(hbuf,&newhead)) return 0; + if(!stream_head_read(hbuf.buf,&newhead)) return 0; goto retry1; } #ifdef DEBUG_RESYNC