diff options
author | Dave Chapman <dave@dchapman.com> | 2005-06-07 20:09:53 +0000 |
---|---|---|
committer | Dave Chapman <dave@dchapman.com> | 2005-06-07 20:09:53 +0000 |
commit | b15e546937c57fec340ff737dbb60a8ec79aab55 (patch) | |
tree | fb3c76c822603483ea763e1be59ed2b21dedb730 /apps/plugins/codecflac.c | |
parent | 3522fc60be04595ef72085360d4594139e8dc5d2 (diff) | |
download | rockbox-b15e546937c57fec340ff737dbb60a8ec79aab55.tar.gz rockbox-b15e546937c57fec340ff737dbb60a8ec79aab55.zip |
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/plugins/codecflac.c')
-rw-r--r-- | apps/plugins/codecflac.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/apps/plugins/codecflac.c b/apps/plugins/codecflac.c index 282f692838..d7159df835 100644 --- a/apps/plugins/codecflac.c +++ b/apps/plugins/codecflac.c | |||
@@ -36,12 +36,11 @@ FLAC__SeekableStreamDecoderReadStatus flac_read_handler(const FLAC__SeekableStre | |||
36 | 36 | ||
37 | *bytes=(unsigned)(ci->read_filebuf(buffer,*bytes)); | 37 | *bytes=(unsigned)(ci->read_filebuf(buffer,*bytes)); |
38 | 38 | ||
39 | /* QUESTION: How do I detect the end of the stream? */ | 39 | if (*bytes==0) { |
40 | if (ci->curpos >= ci->filesize) { | ||
41 | return FLAC__STREAM_DECODER_READ_STATUS_END_OF_STREAM; | 40 | return FLAC__STREAM_DECODER_READ_STATUS_END_OF_STREAM; |
41 | } else { | ||
42 | return FLAC__STREAM_DECODER_READ_STATUS_CONTINUE; | ||
42 | } | 43 | } |
43 | |||
44 | return FLAC__STREAM_DECODER_READ_STATUS_CONTINUE; | ||
45 | } | 44 | } |
46 | 45 | ||
47 | static unsigned char pcmbuf[FLAC_MAX_SUPPORTED_BLOCKSIZE*FLAC_MAX_SUPPORTED_CHANNELS*2] IDATA_ATTR; | 46 | 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) | |||
169 | 168 | ||
170 | /* This function sets up the buffers and reads the file into RAM */ | 169 | /* This function sets up the buffers and reads the file into RAM */ |
171 | 170 | ||
171 | next_track: | ||
172 | |||
172 | if (codec_init(api, ci)) { | 173 | if (codec_init(api, ci)) { |
173 | return PLUGIN_ERROR; | 174 | return PLUGIN_ERROR; |
174 | } | 175 | } |
175 | 176 | ||
176 | /* Create a decoder instance */ | 177 | /* Create a decoder instance */ |
177 | 178 | ||
178 | next_track: | ||
179 | flacDecoder=FLAC__seekable_stream_decoder_new(); | 179 | flacDecoder=FLAC__seekable_stream_decoder_new(); |
180 | 180 | ||
181 | /* Set up the decoder and the callback functions - this must be done before init */ | 181 | /* 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) | |||
212 | FLAC__seekable_stream_decoder_process_single(flacDecoder); | 212 | FLAC__seekable_stream_decoder_process_single(flacDecoder); |
213 | } | 213 | } |
214 | 214 | ||
215 | /* Flush the libFLAC buffers */ | ||
216 | FLAC__seekable_stream_decoder_finish(flacDecoder); | ||
217 | |||
215 | if (ci->request_next_track()) | 218 | if (ci->request_next_track()) |
216 | goto next_track; | 219 | goto next_track; |
217 | 220 | ||