1
0
Fork 0
forked from len0rd/rockbox

Keep track of elapsed time during FLAC playback

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@6637 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Dave Chapman 2005-06-09 09:47:04 +00:00
parent 6271b2b910
commit 7c54b3ad4b

View file

@ -27,6 +27,7 @@
#define FLAC_MAX_SUPPORTED_CHANNELS 2 #define FLAC_MAX_SUPPORTED_CHANNELS 2
static struct plugin_api* rb; static struct plugin_api* rb;
static uint32_t samplesdone;
/* Called when the FLAC decoder needs some FLAC data to decode */ /* Called when the FLAC decoder needs some FLAC data to decode */
FLAC__SeekableStreamDecoderReadStatus flac_read_handler(const FLAC__SeekableStreamDecoder *dec, FLAC__SeekableStreamDecoderReadStatus flac_read_handler(const FLAC__SeekableStreamDecoder *dec,
@ -72,6 +73,9 @@ FLAC__StreamDecoderWriteStatus flac_write_handler(const FLAC__SeekableStreamDeco
} }
} }
samplesdone+=samples;
ci->set_elapsed(samplesdone/(ci->id3->frequency/1000));
while (!ci->audiobuffer_insert(pcmbuf, data_size)) while (!ci->audiobuffer_insert(pcmbuf, data_size))
rb->yield(); rb->yield();
@ -203,6 +207,8 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parm)
/* The first thing to do is to parse the metadata */ /* The first thing to do is to parse the metadata */
FLAC__seekable_stream_decoder_process_until_end_of_metadata(flacDecoder); FLAC__seekable_stream_decoder_process_until_end_of_metadata(flacDecoder);
samplesdone=0;
ci->set_elapsed(0);
/* The main decoder loop */ /* The main decoder loop */
while (FLAC__seekable_stream_decoder_get_state(flacDecoder)!=FLAC__SEEKABLE_STREAM_DECODER_END_OF_STREAM) { while (FLAC__seekable_stream_decoder_get_state(flacDecoder)!=FLAC__SEEKABLE_STREAM_DECODER_END_OF_STREAM) {
rb->yield(); rb->yield();