From 17e6a4940076d81331ebcd4e490bc4423e0e9642 Mon Sep 17 00:00:00 2001 From: James Stembridge Date: Sat, 4 Jun 2005 13:49:25 +0000 Subject: Estimate input time from bitrate CVS patchset: 7605 CVS date: 2005/06/04 13:49:25 --- src/demuxers/demux_aac.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/demuxers/demux_aac.c b/src/demuxers/demux_aac.c index 9ef717307..a2ca6b92e 100644 --- a/src/demuxers/demux_aac.c +++ b/src/demuxers/demux_aac.c @@ -21,7 +21,7 @@ * This demuxer detects ADIF and ADTS headers in AAC files. * Then it shovels buffer-sized chunks over to the AAC decoder. * - * $Id: demux_aac.c,v 1.9 2005/06/04 10:59:36 jstembridge Exp $ + * $Id: demux_aac.c,v 1.10 2005/06/04 13:49:25 jstembridge Exp $ */ #ifdef HAVE_CONFIG_H @@ -126,17 +126,26 @@ static int open_aac_file(demux_aac_t *this) { static int demux_aac_send_chunk(demux_plugin_t *this_gen) { demux_aac_t *this = (demux_aac_t *) this_gen; int bytes_read; + off_t current_pos, length; + uint32_t bitrate; buf_element_t *buf = NULL; /* just load an entire buffer from wherever the audio happens to be */ buf = this->audio_fifo->buffer_pool_alloc (this->audio_fifo); buf->type = BUF_AUDIO_AAC; - if( this->input->get_length (this->input) ) - buf->extra_info->input_normpos = (int)( (double) this->input->get_current_pos (this->input) * - 65535 / this->input->get_length (this->input) ); buf->pts = 0; + length = this->input->get_length(this->input); + current_pos = this->input->get_current_pos(this->input); + bitrate = _x_stream_info_get(this->stream, XINE_STREAM_INFO_AUDIO_BITRATE); + + if (length) + buf->extra_info->input_normpos = (int)((double) current_pos * 65535/length); + + if (bitrate) + buf->extra_info->input_time = (8*current_pos) / (bitrate/1000); + bytes_read = this->input->read(this->input, buf->content, buf->max_size); if (bytes_read == 0) { buf->free_buffer(buf); -- cgit v1.2.3