summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
authorDave Chapman <dave@dchapman.com>2005-06-07 20:09:53 +0000
committerDave Chapman <dave@dchapman.com>2005-06-07 20:09:53 +0000
commitb15e546937c57fec340ff737dbb60a8ec79aab55 (patch)
treefb3c76c822603483ea763e1be59ed2b21dedb730 /apps
parent3522fc60be04595ef72085360d4594139e8dc5d2 (diff)
downloadrockbox-b15e546937c57fec340ff737dbb60a8ec79aab55.zip
rockbox-b15e546937c57fec340ff737dbb60a8ec79aab55.tar.gz
rockbox-b15e546937c57fec340ff737dbb60a8ec79aab55.tar.bz2
rockbox-b15e546937c57fec340ff737dbb60a8ec79aab55.tar.xz
Correctly detect the end of stream, and correctly re-initialise the FLAC decoder before playing the next track.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@6601 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps')
-rw-r--r--apps/plugins/codecflac.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/apps/plugins/codecflac.c b/apps/plugins/codecflac.c
index 282f692..d7159df 100644
--- a/apps/plugins/codecflac.c
+++ b/apps/plugins/codecflac.c
@@ -36,12 +36,11 @@ FLAC__SeekableStreamDecoderReadStatus flac_read_handler(const FLAC__SeekableStre
*bytes=(unsigned)(ci->read_filebuf(buffer,*bytes));
- /* QUESTION: How do I detect the end of the stream? */
- if (ci->curpos >= ci->filesize) {
+ if (*bytes==0) {
return FLAC__STREAM_DECODER_READ_STATUS_END_OF_STREAM;
+ } else {
+ return FLAC__STREAM_DECODER_READ_STATUS_CONTINUE;
}
-
- return FLAC__STREAM_DECODER_READ_STATUS_CONTINUE;
}
static unsigned char pcmbuf[FLAC_MAX_SUPPORTED_BLOCKSIZE*FLAC_MAX_SUPPORTED_CHANNELS*2] IDATA_ATTR;
@@ -169,13 +168,14 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parm)
/* This function sets up the buffers and reads the file into RAM */
+ next_track:
+
if (codec_init(api, ci)) {
return PLUGIN_ERROR;
}
/* Create a decoder instance */
- next_track:
flacDecoder=FLAC__seekable_stream_decoder_new();
/* Set up the decoder and the callback functions - this must be done before init */
@@ -212,6 +212,9 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parm)
FLAC__seekable_stream_decoder_process_single(flacDecoder);
}
+ /* Flush the libFLAC buffers */
+ FLAC__seekable_stream_decoder_finish(flacDecoder);
+
if (ci->request_next_track())
goto next_track;