[xiph-commits] r3588 - libannodex/trunk/src/importers

johnf at svn.annodex.net johnf at svn.annodex.net
Sun May 4 21:20:37 PDT 2008


Author: johnf
Date: 2008-05-04 21:20:37 -0700 (Sun, 04 May 2008)
New Revision: 3588

Modified:
   libannodex/trunk/src/importers/anx_import_ogg.c
Log:
* If we are asked for an end_time past the end of the file then return to the end of the file
* If we are asked for a start_time past the end of the file return an error
* Actually check the return status of anxogg_setup


Modified: libannodex/trunk/src/importers/anx_import_ogg.c
===================================================================
--- libannodex/trunk/src/importers/anx_import_ogg.c	2008-05-05 04:07:37 UTC (rev 3587)
+++ libannodex/trunk/src/importers/anx_import_ogg.c	2008-05-05 04:20:37 UTC (rev 3588)
@@ -980,6 +980,21 @@
   start_time = aod->anx_source->start_time;
   end_time = aod->anx_source->end_time;
 
+  /* Check if the end_time is bigger than the end of the file */
+  units_at = oggz_seek_units (aod->oggz, 0, SEEK_END);
+  if (units_at == -1) {
+#ifdef DEBUG
+      fprintf (aod->df, "anxogg_setup: oggz_seek_units end FAIL\n");
+#endif
+      return -1;
+  } else {
+      int actual_end_time;
+
+      actual_end_time = ((double)units_at) / 1000.0;
+
+      end_time = -1.0 if (end_time > actual_end_time);
+  }
+
   if (end_time == -1.0) {
 #ifdef DEBUG
     fprintf(aod->df, "calling oggz_seek with whence of %d\n", SEEK_END);
@@ -989,17 +1004,6 @@
     fprintf (aod->df, "anxogg_setup: end_offset is %d\n", end_offset);
 #endif
 
-    /* Find the actual end time */
-    units_at = oggz_seek_units (aod->oggz, 0, SEEK_END);
-    if (units_at == -1) {
-#ifdef DEBUG
-      fprintf (aod->df, "anxogg_setup: oggz_seek_units end FAIL\n");
-#endif
-      //return -1;
-      end_time = -1;
-    } else {
-      end_time = ((double)units_at) / 1000.0;
-    }
   } else {
     units = (ogg_int64_t)(SUBSECONDS * end_time);
     units_at = oggz_seek_units (aod->oggz, units, SEEK_SET);
@@ -1145,7 +1149,9 @@
   fprintf (aod->df, "anxogg: open %s t=%f\n", path, start_time);
 #endif
 
-  anxogg_setup (aod);
+  if (anxogg_setup (aod) != 0) {
+      return NULL;
+  }
 
   /* Set normal data reading callback */
   oggz_set_read_callback (oggz, -1, read_packet_data, aod);



More information about the commits mailing list