diff src/madplug/decoder.c @ 997:e46b98155d5d trunk

[svn] - fix a bug which counts number of frames twice in handling xing header. - now fileinfo dialog calculates play length even though TLEN tag exists so that it can overwrite wrong TLEN tag.
author yaz
date Tue, 01 May 2007 12:49:27 -0700
parents 6ba4a4bfd127
children 29519d604e8c
line wrap: on
line diff
--- a/src/madplug/decoder.c	Tue May 01 10:38:27 2007 -0700
+++ b/src/madplug/decoder.c	Tue May 01 12:49:27 2007 -0700
@@ -191,6 +191,11 @@
     info->pos = mad_timer_zero;
     info->duration = mad_timer_zero; // should be cleared before loop, if we use it as break condition.
 
+    if(info->fileinfo_request == TRUE) {
+        info->tuple->length = -1;
+        info->fileinfo_request = FALSE;
+    }
+
 #ifdef DEBUG
     g_message("f: scan_file");
     g_message("scan_file frames = %d", info->frames);
@@ -294,9 +299,10 @@
 #endif                          /* DEBUG */
                         has_xing = TRUE;
                         info->vbr = TRUE;   /* otherwise xing header would have been 'Info' */
-                        info->frames = info->xing.frames;
-                        if(info->tuple->length == -1)
-                            mad_timer_multiply(&info->duration, info->frames);
+                        if(info->tuple->length == -1) {
+                            info->duration = mad_timer_zero;
+                            mad_timer_multiply(&info->duration, info->xing.frames);
+                        }
                         else {
                             info->duration.seconds = info->tuple->length / 1000;
                             info->duration.fraction = info->tuple->length % 1000;
@@ -378,6 +384,9 @@
             break;
     }
 
+    if (info->xing.frames)
+        info->frames = info->xing.frames;
+
     if (info->vbr && xing_bitrate != 0) {
         info->bitrate = xing_bitrate;
     }