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: diff --git a/firmware/pcm_playback.c b/firmware/pcm_playback.c index 049978e381..a4978d645b 100644 --- a/firmware/pcm_playback.c +++ b/firmware/pcm_playback.c @@ -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))