From 7c54b3ad4b10cd58573a180a8bff5166c36e5580 Mon Sep 17 00:00:00 2001 From: Dave Chapman Date: Thu, 9 Jun 2005 09:47:04 +0000 Subject: Keep track of elapsed time during FLAC playback git-svn-id: svn://svn.rockbox.org/rockbox/trunk@6637 a1c6a512-1295-4272-9138-f99709370657 --- apps/plugins/codecflac.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'apps/plugins') diff --git a/apps/plugins/codecflac.c b/apps/plugins/codecflac.c index d7159df835..57089ee9a3 100644 --- a/apps/plugins/codecflac.c +++ b/apps/plugins/codecflac.c @@ -27,6 +27,7 @@ #define FLAC_MAX_SUPPORTED_CHANNELS 2 static struct plugin_api* rb; +static uint32_t samplesdone; /* Called when the FLAC decoder needs some FLAC data to decode */ 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)) 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 */ FLAC__seekable_stream_decoder_process_until_end_of_metadata(flacDecoder); + samplesdone=0; + ci->set_elapsed(0); /* The main decoder loop */ while (FLAC__seekable_stream_decoder_get_state(flacDecoder)!=FLAC__SEEKABLE_STREAM_DECODER_END_OF_STREAM) { rb->yield(); -- cgit v1.2.3