2006-09-04: EV dixit:
> [...]
> For the moment, I've patched rio_rw.c so as to override the
> length property computed by lk_rio_update_props_from_tags with
> a correct file length. Then duration is computed from the
> bitrate provided by libtag.  I hope libtag can compute an
> adequate bitrate estimate for VBR files (I don't have VBR files
> to test with);  otherwise, the duration will be wrong for VBR
> MP3 files.
> 
> The RK needs duration for scrolling and showing play progress.
> 
> I'll send the patch this night, hopefully.

Here it is.  I take the rio_cp.c modifications just as temporary
workarounds to allow me finishing lkarmafs-0.1.9.  As such, I've
clearly marked the modified parts so Keith or Franky (who are
familiar with libtag) can easyly identify and eventually improve
the corresponding code.  Other minor modifications were needed to
make some error returns correct, also needed by lkarmafs.

Lkarmafs-0.1.9 is not ready yet.  May be along the weekend...

Best,
EV.
# HG changeset patch
# User [EMAIL PROTECTED]
# Node ID 2e67a844b89672dfa7db4ad0688bc5488ce12f1a
# Parent  55504467ace5be77c808c9174911e42af4bfb36e
Fixed bad length/duration yield by update_props_from_tags()

diff -r 55504467ace5 -r 2e67a844b896 ChangeLog
--- a/ChangeLog Sat Sep  2 22:36:09 2006
+++ b/ChangeLog Tue Sep  5 21:59:58 2006
@@ -1,5 +1,6 @@
 0.0.6:
-       * Added support for calculating rids correctly in lkarmafs
+       * Fixed bad length & duration yield by lk_rio_update_props_from_tags()
+       * Added lk_rio_update_props_from_tags() to get correct rids in lkarmafs
        * Changed sorting tracks by artist to match "Rescan music" functionality
        * Changed device settings: don't use properties not held in smalldb
         * Re-implemented fdb support and made it functional
diff -r 55504467ace5 -r 2e67a844b896 src/fdb.c
--- a/src/fdb.c Sat Sep  2 22:36:09 2006
+++ b/src/fdb.c Tue Sep  5 21:59:58 2006
@@ -181,7 +181,7 @@
     char * id, * path, * tm;
     uint32_t * fdb;
     HASH * tmp;
-    int i=0, first=1;
+    int i=0, first=1, ret=0;
 
     fname=lk_path_string(FDB_FILENAME);
     fdb_file=gzopen(fname, "w");
@@ -236,15 +236,14 @@
         free(fdb);
         gzclose(fdb_file);
     }
-    lk_rio_write_fdb(rio, fname);
-
+    ret = lk_rio_write_fdb(rio, fname);
     /*
      * Datenbank auf Karma als Taxifile kopieren...
      */
     free(fname);
     fdb_updated = 0;
 
-    return 0;
+    return ret;
 }
 
 void lk_fdb_set_device(int karma)
diff -r 55504467ace5 -r 2e67a844b896 src/properties.c
--- a/src/properties.c  Sat Sep  2 22:36:09 2006
+++ b/src/properties.c  Tue Sep  5 21:59:58 2006
@@ -329,9 +329,6 @@
     char * buf;
     struct utimbuf time;
 
-    if (fdb_updated != 0)
-        lk_fdb_save();
-
     if (properties_updated == 0)
         return 0;
 
@@ -367,6 +364,10 @@
     }
 
     free(fname);
+
+    if (fdb_updated != 0)
+        return lk_fdb_save();
+
     return 0;
 }
 
diff -r 55504467ace5 -r 2e67a844b896 src/rio_rw.c
--- a/src/rio_rw.c      Sat Sep  2 22:36:09 2006
+++ b/src/rio_rw.c      Tue Sep  5 21:59:58 2006
@@ -43,7 +43,10 @@
 static void add_general(HASH * p, const char *filename);
 static int get_ogg_props(HASH *p, const char *filename);
 static int get_flac_props(HASH *p, const char *filename);
-static int get_mp3_props(HASH *p, mp3info *mp3);
+/* *********************** EV *********************** */
+/* static int get_mp3_props(HASH *p, mp3info *mp3); */
+static int get_mp3_props(HASH *p, mp3info *mp3, uint64_t length);
+/* ************************************************** */
 static int get_taxi_props(HASH *p);
 static int get_wave_props(HASH *p, const char *filename);
 static void add_tag(HASH *p, char *key, char *value);
@@ -132,7 +135,8 @@
     struct stat len;
     HASH * props;
     mp3info mp3;
-    char *rid;
+    char *rid, *tmp;
+    uint64_t length=0;
     int type, rid_fd;
 /** uint32_t *fids; **/
 
@@ -155,6 +159,13 @@
         return -1;
     }
 
+    /* *********************** EV *********************** */
+    /* to fix bad length & duration yield by lk_rio_do_update_props_from_tags 
*/
+    tmp = lk_properties_get_property(fid, "length");
+    if(tmp != NULL)
+      length = strtoull(tmp, NULL, 10);
+    /* ************************************************** */
+
     add_general(props, filename);
     lk_properties_set_property_hash(props, "rid", rid);
 
@@ -163,7 +174,10 @@
     else if (type == TYPE_FLAC)
         got=get_flac_props(props, filename);
     else if (type == TYPE_MP3)
-        got=get_mp3_props(props, &mp3);
+        /* *********************** EV *********************** */
+        /* got=get_mp3_props(props, &mp3); */
+        got=get_mp3_props(props, &mp3, length);
+        /* ************************************************** */
     else if (type == TYPE_WAV)
         got=get_wave_props(props, filename);
     /*
@@ -440,9 +454,12 @@
     return set_tag_props(p, filename, TagLib_File_FLAC);
 }
 
-static int get_mp3_props(HASH *p, mp3info *mp3)
-{
-    int ret = 0;
+/* *********************** EV *********************** */
+/* static int get_mp3_props(HASH *p, mp3info *mp3) */
+static int get_mp3_props(HASH *p, mp3info *mp3, uint64_t length)
+/* ************************************************** */
+{
+    int ret = 0, brate = 0;
     char bitrate[5];
     
     lk_properties_set_property_hash(p, "type", "tune");
@@ -457,9 +474,19 @@
     ret = set_tag_props(p, mp3->filename, TagLib_File_MPEG);
     
     if(!mp3->vbr){
+        /* *********************** EV *********************** */
+        brate = header_bitrate(&mp3->header);
         strcpy(bitrate, "fs");
-        strcat(bitrate, simple_itoa(header_bitrate(&mp3->header)));
+        strcat(bitrate, simple_itoa(brate));
         lk_properties_set_property_hash(p, "bitrate", bitrate);
+        /* fixing bad length & duration yield
+           by lk_rio_do_update_props_from_tags */
+       if(length>0) {
+            lk_properties_set_property_hash(p, "length", simple_itoa(length));
+            lk_properties_set_property_hash(p, "duration", 
+                                               simple_itoa(8*(length/brate)));
+       }
+        /* ************************************************** */
     }
     
     return ret;
diff -r 55504467ace5 -r 2e67a844b896 tools/riocp.c
--- a/tools/riocp.c     Sat Sep  2 22:36:09 2006
+++ b/tools/riocp.c     Tue Sep  5 21:59:58 2006
@@ -27,7 +27,7 @@
 #include <lkarma.h>
 #include "pathedit.h"
 
-#define CHECK(x) (x)?"failed":"ok"
+#define CHECK(x) (x<0)?"failed":"ok"
 
 #define defaultCodeset "ISO8859-15"
 
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
linux-karma-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-karma-devel

Reply via email to