changeset 24451:abcfa91fcc9a

Simplify tmf_filetooffset
author reimar
date Fri, 14 Sep 2007 16:42:46 +0000
parents d8b25c8a4ea4
children f71e3d4c2816
files libmpdemux/demux_ty.c
diffstat 1 files changed, 9 insertions(+), 21 deletions(-) [+]
line wrap: on
line diff
--- a/libmpdemux/demux_ty.c	Fri Sep 14 16:21:12 2007 +0000
+++ b/libmpdemux/demux_ty.c	Fri Sep 14 16:42:46 2007 +0000
@@ -260,27 +260,15 @@
 
 
 // ===========================================================================
-static void tmf_filetooffset( TiVoInfo *tivo, int chunk, off_t *offset )
+static off_t tmf_filetooffset(TiVoInfo *tivo, int chunk)
 {
-   int index;
-
-   *offset = 0;
-
-   for( index = 0 ; index < tivo->tmf_totalparts ; index++ )
-   {
-      if ( chunk >= tivo->tmfparts[ index ].chunks )
-         chunk -= tivo->tmfparts[ index ].chunks;
-      else
-         break;
-   }
-   if ( chunk < tivo->tmfparts[ index ].chunks )
-      *offset = tivo->tmfparts[ index ].startOffset +
-         chunk * CHUNKSIZE;
-   mp_msg
-   ( 
-      MSGT_DEMUX, MSGL_DBG3, 
-      "tmf_filetooffset() offset %"PRIx64"\n", *offset
-   );
+  int i;
+  for (i = 0; i < tivo->tmf_totalparts; i++) {
+    if (chunk < tivo->tmfparts[i].chunks)
+      return tivo->tmfparts[i].startOffset + chunk * CHUNKSIZE;
+    chunk -= tivo->tmfparts[i].chunks;
+  }
+  return -1;
 }
 
 
@@ -305,7 +293,7 @@
       return( 0 );
    }
 
-   tmf_filetooffset( tivo, readChunk, &fileoffset );
+   fileoffset = tmf_filetooffset(tivo, readChunk);
 
    if ( stream_seek( demux->stream, fileoffset ) != 1 )
    {