summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJosh Coalson <jcoalson@users.sourceforce.net>2003-01-04 01:04:41 +0000
committerJosh Coalson <jcoalson@users.sourceforce.net>2003-01-04 01:04:41 +0000
commitc2b6a11db90d121a6b9591f374dea61ae3c23949 (patch)
tree85be95929ea02728d1231a11d2e1c1b19ca50a67 /src
parent27784e9fa4c3217ee50a0f831033da436e1d1b9e (diff)
downloadflac-c2b6a11db90d121a6b9591f374dea61ae3c23949.tar.gz
patch from Miroslav to fix bitrate display for large blocksize or small sample rate
Diffstat (limited to 'src')
-rw-r--r--src/plugin_xmms/plugin.c21
1 files changed, 14 insertions, 7 deletions
diff --git a/src/plugin_xmms/plugin.c b/src/plugin_xmms/plugin.c
index 24eb1774..c918826b 100644
--- a/src/plugin_xmms/plugin.c
+++ b/src/plugin_xmms/plugin.c
@@ -310,14 +310,17 @@ void FLAC_XMMS__get_song_info(char *filename, char **title, int *length_in_msec)
void *play_loop_(void *arg)
{
- unsigned written_time_last = 0, bh_index_last_w = 0, bh_index_last_o = BITRATE_HIST_SIZE;
- FLAC__uint64 decode_position_last = 0;
+ unsigned written_time_last = 0, bh_index_last_w = 0, bh_index_last_o = BITRATE_HIST_SIZE, blocksize = 1;
+ FLAC__uint64 decode_position_last = 0, decode_position_frame_last = 0, decode_position_frame = 0;
(void)arg;
while(file_info_.is_playing) {
if(!file_info_.eof) {
while(wide_samples_in_reservoir_ < SAMPLES_PER_WRITE) {
+ unsigned s;
+
+ s = wide_samples_in_reservoir_;
if(FLAC__file_decoder_get_state(decoder_) == FLAC__FILE_DECODER_END_OF_FILE) {
file_info_.eof = true;
break;
@@ -328,6 +331,10 @@ void *play_loop_(void *arg)
file_info_.eof = true;
break;
}
+ blocksize = wide_samples_in_reservoir_ - s;
+ decode_position_frame_last = decode_position_frame;
+ if(!FLAC__file_decoder_get_decode_position(decoder_, &decode_position_frame))
+ decode_position_frame = 0;
}
if(wide_samples_in_reservoir_ > 0) {
const unsigned channels = file_info_.channels;
@@ -379,12 +386,10 @@ void *play_loop_(void *arg)
/* compute current bitrate */
written_time = flac_ip.output->written_time();
- bh_index_w = written_time / BITRATE_HIST_SEGMENT_MSEC % BITRATE_HIST_SIZE ;
- if(bh_index_w != bh_index_last_w && wide_samples_in_reservoir_ < SAMPLES_PER_WRITE) {
+ bh_index_w = written_time / BITRATE_HIST_SEGMENT_MSEC % BITRATE_HIST_SIZE;
+ if(bh_index_w != bh_index_last_w) {
bh_index_last_w = bh_index_w;
- if(!FLAC__file_decoder_get_decode_position(decoder_, &decode_position))
- decode_position = 0;
-
+ decode_position = decode_position_frame - (double)wide_samples_in_reservoir_ * (double)(decode_position_frame - decode_position_frame_last) / (double)blocksize;
bitrate_history_[(bh_index_w + BITRATE_HIST_SIZE - 1) % BITRATE_HIST_SIZE] =
decode_position > decode_position_last && written_time > written_time_last ?
8000 * (decode_position - decode_position_last) / (written_time - written_time_last) :
@@ -406,6 +411,8 @@ void *play_loop_(void *arg)
if(FLAC__file_decoder_seek_absolute(decoder_, (FLAC__uint64)target_sample)) {
flac_ip.output->flush(file_info_.seek_to_in_sec * 1000);
bh_index_last_w = bh_index_last_o = flac_ip.output->output_time() / BITRATE_HIST_SEGMENT_MSEC % BITRATE_HIST_SIZE;
+ if(!FLAC__file_decoder_get_decode_position(decoder_, &decode_position_frame))
+ decode_position_frame = 0;
file_info_.seek_to_in_sec = -1;
file_info_.eof = false;
wide_samples_in_reservoir_ = 0;