From d30f1100ec8d74f3c187271590b03d589ad4b7dc Mon Sep 17 00:00:00 2001 From: Miika Pekkarinen Date: Fri, 10 Jun 2005 17:33:16 +0000 Subject: Much better UI performance and buffering times for MP3 and FLAC. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@6653 a1c6a512-1295-4272-9138-f99709370657 --- apps/plugins/codecflac.c | 5 +++++ apps/plugins/codecmpa.c | 8 +++++++- apps/plugins/codecvorbis.c | 1 + 3 files changed, 13 insertions(+), 1 deletion(-) (limited to 'apps/plugins') diff --git a/apps/plugins/codecflac.c b/apps/plugins/codecflac.c index d577006440..8d0653e364 100644 --- a/apps/plugins/codecflac.c +++ b/apps/plugins/codecflac.c @@ -57,6 +57,7 @@ FLAC__StreamDecoderWriteStatus flac_write_handler(const FLAC__SeekableStreamDeco unsigned int c_samp, c_chan, d_samp; uint32_t data_size = frame->header.blocksize * frame->header.channels * 2; /* Assume 16-bit words */ uint32_t samples = frame->header.blocksize; + int yieldcounter = 0; if (samples*frame->header.channels > (FLAC_MAX_SUPPORTED_BLOCKSIZE*FLAC_MAX_SUPPORTED_CHANNELS)) { @@ -70,6 +71,10 @@ FLAC__StreamDecoderWriteStatus flac_write_handler(const FLAC__SeekableStreamDeco for(c_chan = 0; c_chan < frame->header.channels; c_chan++, d_samp++) { pcmbuf[d_samp*2] = (buf[c_chan][c_samp]&0xff00)>>8; pcmbuf[(d_samp*2)+1] = buf[c_chan][c_samp]&0xff; + if (yieldcounter++ == 100) { + rb->yield(); + yieldcounter = 0; + } } } diff --git a/apps/plugins/codecmpa.c b/apps/plugins/codecmpa.c index 88f6b8c624..bf6cf3f87d 100644 --- a/apps/plugins/codecmpa.c +++ b/apps/plugins/codecmpa.c @@ -198,6 +198,7 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parm) int fd; #endif int i; + int yieldcounter = 0; /* Generic plugin inititialisation */ @@ -217,6 +218,7 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parm) /* Create a decoder instance */ ci->configure(CODEC_SET_FILEBUF_LIMIT, (int *)(1024*1024*2)); + ci->configure(CODEC_SET_FILEBUF_CHUNKSIZE, (int *)(1024*16)); next_track: memset(&Stream, 0, sizeof(struct mad_stream)); @@ -379,10 +381,14 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parm) goto song_end; } + if (yieldcounter++ == 200) { + rb->yield(); + yieldcounter = 0; + } + /* Flush the buffer if it is full. */ if(OutputPtr==OutputBufferEnd) { - rb->yield(); #ifdef DEBUG_GAPLESS rb->write(fd, OutputBuffer, OUTPUT_BUFFER_SIZE); #endif diff --git a/apps/plugins/codecvorbis.c b/apps/plugins/codecvorbis.c index c1ccdfd3fa..6c512f7ce4 100644 --- a/apps/plugins/codecvorbis.c +++ b/apps/plugins/codecvorbis.c @@ -105,6 +105,7 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parm) #endif ci->configure(CODEC_SET_FILEBUF_LIMIT, (int *)(1024*1024*2)); + ci->configure(CODEC_SET_FILEBUF_CHUNKSIZE, (int *)(1024*32)); /* We need to flush reserver memory every track load. */ next_track: -- cgit v1.2.3