diff src/madplug/plugin.c @ 738:6ea974a229a8 trunk

[svn] - add read/write support for TLEN frame.
author yaz
date Tue, 27 Feb 2007 04:17:49 -0800
parents 1733b12ef974
children 7ffb93bce2d2
line wrap: on
line diff
--- a/src/madplug/plugin.c	Tue Feb 27 03:45:34 2007 -0800
+++ b/src/madplug/plugin.c	Tue Feb 27 04:17:49 2007 -0800
@@ -402,7 +402,10 @@
             *title = strdup(myinfo.tuple->track_name);
         else
             *title = strdup(url);
-        *length = mad_timer_count(myinfo.duration, MAD_UNITS_MILLISECONDS);
+        if(myinfo.tuple->length == -1)
+            *length = mad_timer_count(myinfo.duration, MAD_UNITS_MILLISECONDS);
+        else
+            *length = myinfo.tuple->length;
     }
     else {
         *title = strdup(url);
@@ -555,7 +558,17 @@
                 tuple->file_ext = extname(filename);
 
                 // length
-                {
+                tuple->length = -1;
+                string = input_id3_get_string(tag, "TLEN");
+                if (string) {
+                    tuple->length = atoi(string);
+#ifdef DEBUG
+                    printf("get_song_tuple: TLEN = %d\n", tuple->length);
+#endif	
+                    g_free(string);
+                    string = NULL;
+                }
+                else {
                     char *dummy = NULL;
                     int length = 0;
                     audmad_get_song_info(filename, &dummy, &length);
@@ -582,7 +595,7 @@
             }
             id3_file_close(id3file);
         }
-        else {
+        else { // no id3tag
             tuple->file_name = g_path_get_basename(filename);
             tuple->file_path = g_path_get_dirname(filename);
             tuple->file_ext = extname(filename);
@@ -590,8 +603,10 @@
             {
                 char *dummy = NULL;
                 int length = 0;
-                audmad_get_song_info(filename, &dummy, &length);
-                tuple->length = length;
+                if(tuple->length == -1) {
+                    audmad_get_song_info(filename, &dummy, &length);
+                    tuple->length = length;
+                }
                 g_free(dummy);
             }
         }