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
This commit is contained in:
Miika Pekkarinen 2005-06-10 17:33:16 +00:00
parent 68b9acd7de
commit d30f1100ec
4 changed files with 15 additions and 2 deletions

View file

@ -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;
}
}
}

View file

@ -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

View file

@ -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:

View file

@ -351,7 +351,8 @@ void pcm_watermark_callback(int bytes_left)
void pcm_set_boost_mode(bool state)
{
boost_mode = state;
pcm_boost(state);
if (state)
pcm_boost(true);
}
void audiobuffer_add_event(void (*event_handler)(void))