--- rockbox-svn-trunk/apps/buffering.c 2008-12-26 12:59:48.681800000 -0500 +++ rockbox-19669-dma/apps/buffering.c 2009-01-05 21:19:00.482000000 -0500 @@ -692,7 +692,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; @@ -932,8 +936,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); @@ -946,7 +952,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;