Index: apps/playback.c =================================================================== --- apps/playback.c (revision 23773) +++ apps/playback.c (working copy) @@ -115,6 +115,9 @@ static size_t filebuflen = 0; /* Size of buffer (A/C-) */ /* FIXME: make buf_ridx (C/A-) */ +#define NO_FILEBUFCODEC 150000 +/* If filebuflen to small do not load codec in ringbuffer */ + /* Possible arrangements of the buffer */ enum audio_buffer_state { @@ -1081,6 +1084,9 @@ } } + if (filebuflen < NO_FILEBUFCODEC) + return true; + codec_get_full_path(codec_path, codec_fn); tracks[track_widx].codec_hid = bufopen(codec_path, 0, TYPE_CODEC, NULL); @@ -1849,7 +1855,7 @@ /* Make sure filebuflen is a longword multiple after adjustment - filebuf will already be line aligned */ - filebuflen &= ~3; + filebuflen &= ~15; buffering_reset(filebuf, filebuflen); Index: apps/buffering.c =================================================================== --- apps/buffering.c (revision 23773) +++ apps/buffering.c (working copy) @@ -248,8 +248,8 @@ } } - /* align to 4 bytes up */ - new_widx = RINGBUF_ADD(buf_widx, 3) & ~3; + /* align to 16 bytes up */ + new_widx = RINGBUF_ADD(buf_widx, 15) & ~15; len = data_size + sizeof(struct memory_handle); @@ -420,8 +420,8 @@ size_to_move = sizeof(struct memory_handle) + data_size; - /* Align to four bytes, down */ - final_delta &= ~3; + /* Align to 16 bytes, down */ + final_delta &= ~15; if (final_delta < sizeof(struct memory_handle)) { /* It's not legal to move less than the size of the struct */ return false; @@ -450,8 +450,8 @@ correction = overlap - data_size; } if (correction) { - /* Align correction to four bytes up */ - correction = (correction + 3) & ~3; + /* Align correction to 16 bytes up */ + correction = (correction + 15) & ~15; if (final_delta < correction + sizeof(struct memory_handle)) { /* Delta cannot end up less than the size of the struct */ mutex_unlock(&llist_mod_mutex); @@ -494,29 +494,37 @@ /* Copying routine takes into account that the handles have a - * distance between each other which is a multiple of four. Faster 2 word - * copy may be ok but do this for safety and because wrapped copies should - * be fairly uncommon */ + * distance between each other which is a multiple of 16 bytes. + * It distinguishes between move of memory_handle struct only which + * cannot wrap and move of struct and data with a fast routine + * taking into account a wrapped handle */ - here = (int32_t *)((RINGBUF_ADD(oldpos, size_to_move - 1) & ~3)+ (intptr_t)buffer); - there =(int32_t *)((RINGBUF_ADD(newpos, size_to_move - 1) & ~3)+ (intptr_t)buffer); + if ( data_size == 0){ + /* struct only for package audio handle */ + memmove(dest,src,size_to_move); + } + else { + /* the other handles with data */ + size_to_move = (size_to_move & ~15) + 13; + + here = (int32_t *)(RINGBUF_ADD(oldpos, size_to_move - 1) + (intptr_t)buffer); + there =(int32_t *)(RINGBUF_ADD(newpos, size_to_move - 1) + (intptr_t)buffer); end = (int32_t *)(( intptr_t)buffer + buffer_len - 4); begin =(int32_t *)buffer; - n = (size_to_move & ~3)/4; + n = (size_to_move + 3)/16; - if ( overlap_old > 0 || overlap > 0 ) { - /* Old or moved handle wraps */ - while (n--) { - if (here < begin) - here = end; - if (there < begin) + + while (n--) { + if (here < begin) + here = end; + if (there < begin) there = end; *there-- = *here--; - } - } else { - /* both handles do not wrap */ - memmove(dest,src,size_to_move); + *there-- = *here--; + *there-- = *here--; + *there-- = *here--; + } }