Re: [AVFS] amarok skips the initial part of files accessed via avfs+fuse

Ralf Hoffmann <[email protected]> Wed, 09 May 2007 21:51:35 +0200
Newsgroups gmane.comp.file-systems.avfs.user
Message-ID <[email protected]>
This is a multi-part message in MIME format.
--------------020805050903020005080203
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Hi,

On 2007-05-02 23:09, Giuseppe Bilotta wrote:
> Before the patch, when I loaded a bunch of tracks (located into zip
> files) into amarok taglib would fail to open the file and thus it
> would not be able to determine tagging information and song length. If
> I played all the songs one after the other, they would all play
> correctly, but if I started skipping around (play 5 after 3 or replay
> all the songs once they were finished), I could distinctly hear parts
> of the song missing from the beginning.
> 
> After the patch, song length and tags are determined correctly, but
> playing *any* song seems to drop the first seconds. I've tried copying
> the files from the avfs-mounted zip to a physicial partition, and they
> play correctly; cmp'ing them with the unzipper contents show no
> difference. But when I play them from within the zip the initial part
> of the song disappears.

I looked into this problem and was able to reproduce it. The problem 
lies in the uzip module (actually it's the file zread.c which is used by 
uzip).

The bug is triggered by seeking to the end of a file in a zip archive 
and back to the beginning. This is done by mplayer/xine/amarok/whatever 
(probably ID3 tags at the end of the file).

When seeking back to the beginning, a previously stored zlib stream is 
used but the flag iseof is not restored.

I propose the attached patch, could you please try it and report whether 
it solved your problems? It works for me but I only tested mplayer not 
amarok.

Miklos, you wrote the zread code (some years ago :-) ), do you think the 
patch is okay?

Best Regards,

Ralf Hoffmann

-- 
Homepage: http://www.boomerangsworld.de
E-Mail: Ralf Hoffmann <[email protected]>
   English or German

--------------020805050903020005080203
Content-Type: text/plain;
 name="avfs-zread.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="avfs-zread.patch"

diff --git a/src/zread.c b/src/zread.c
index 0247186..5b5cfcb 100644
--- a/src/zread.c
+++ b/src/zread.c
@@ -28,6 +28,7 @@ struct streamcache {
     int id;
     z_stream s;
     int calccrc;
+    int iseof;
 };
 
 static struct streamcache scache;
@@ -150,7 +151,7 @@ static void zfile_scache_cleanup(void)
     inflateEnd(&scache.s);
 }
 
-static void zfile_scache_save(int id, z_stream *s, int calccrc)
+static void zfile_scache_save(int id, z_stream *s, int calccrc, int iseof)
 {
     int res;
 
@@ -176,6 +177,7 @@ static void zfile_scache_save(int id, z_
     scache.id = id;
     scache.s = *s;
     scache.calccrc = calccrc;
+    scache.iseof = iseof;
 }
 
 static int zfile_reset(struct zfile *fil)
@@ -183,7 +185,7 @@ static int zfile_reset(struct zfile *fil
     int res;
 
     /* FIXME: Is it a good idea to save the previous state or not? */
-    zfile_scache_save(fil->id, &fil->s, fil->calccrc);
+    zfile_scache_save(fil->id, &fil->s, fil->calccrc, fil->iseof);
     memset(&fil->s, 0, sizeof(z_stream));
     res = inflateInit2(&fil->s, -MAX_WBITS);
     if(res != Z_OK) {
@@ -272,7 +274,7 @@ static int zfile_seek_index(struct zfile
     char *state;
 
     /* FIXME: Is it a good idea to save the previous state or not? */
-    zfile_scache_save(fil->id, &fil->s, fil->calccrc);
+    zfile_scache_save(fil->id, &fil->s, fil->calccrc, fil->iseof);
     memset(&fil->s, 0, sizeof(z_stream));
 
     fd = open(zc->indexfile, O_RDONLY, 0);
@@ -452,11 +454,14 @@ static int zfile_seek(struct zfile *fil,
         if((dist == -1 || scdist < dist) && scdist < zcdist) {
             z_stream tmp = fil->s;
             int tmpcc = fil->calccrc;
+            int tmpiseof = fil->iseof;
             fil->s = scache.s;
             fil->s.avail_in = 0;
             fil->calccrc = scache.calccrc;
+            fil->iseof = scache.iseof;
             scache.s = tmp;
             scache.calccrc = tmpcc;
+            scache.iseof = tmpiseof;
             return 0;
         }
     }
@@ -556,7 +561,7 @@ int av_zfile_size(struct zfile *fil, str
 static void zfile_destroy(struct zfile *fil)
 {
     AV_LOCK(zread_lock);
-    zfile_scache_save(fil->id, &fil->s, fil->calccrc);
+    zfile_scache_save(fil->id, &fil->s, fil->calccrc, fil->iseof);
     AV_UNLOCK(zread_lock);
 }
 

--------------020805050903020005080203
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
--------------020805050903020005080203
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
Avf-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/avf-user

--------------020805050903020005080203--