Index: apps/buffering.c =================================================================== --- apps/buffering.c (revision 19983) +++ apps/buffering.c (working copy) @@ -86,7 +86,7 @@ /* default point to start buffer refill */ #define BUFFERING_DEFAULT_WATERMARK (1024*128) /* amount of data to read in one read() call */ -#define BUFFERING_DEFAULT_FILECHUNK (1024*32) +#define BUFFERING_DEFAULT_FILECHUNK (1024*256) /* AB: enlarged to 256KB */ #define BUF_HANDLE_MASK 0x7FFFFFFF @@ -685,7 +685,11 @@ if (!h) return; - h->ridx = h->widx = h->data; + /* Align sector boundaries so reads are aligned */ + h->widx = h->data; + h->ridx = h->data + (h->offset & 3); + h->offset &= ~3; + if (h == cur_handle) buf_widx = h->widx; h->available = 0; @@ -925,8 +929,10 @@ size_t size = filesize(fd); bool can_wrap = type==TYPE_PACKET_AUDIO || type==TYPE_CODEC; - size_t adjusted_offset = offset; - if (adjusted_offset > size) + /* Align sector boundaries so reads are aligned */ + size_t adjusted_offset = offset & ~3; + + if (adjusted_offset > size) adjusted_offset = 0; struct memory_handle *h = add_handle(size-adjusted_offset, can_wrap, false); @@ -939,7 +945,7 @@ strncpy(h->path, file, MAX_PATH); h->offset = adjusted_offset; - h->ridx = buf_widx; + h->ridx = buf_widx + (offset & 3); h->data = buf_widx; h->type = type;