[xiph-commits] r3303 - liboggz/trunk/src/liboggz

conrad at svn.annodex.net conrad at svn.annodex.net
Fri Dec 7 13:54:30 PST 2007


Author: conrad
Date: 2007-12-07 13:54:24 -0800 (Fri, 07 Dec 2007)
New Revision: 3303

Modified:
   liboggz/trunk/src/liboggz/oggz_write.c
Log:
in oggz_write_output(), break out of the packet-making loop unconditionally
when the users's hungry callback returns != OGGZ_CONTINUE.
Fixes spinning of oggz-validate introduced in changesset:3293


Modified: liboggz/trunk/src/liboggz/oggz_write.c
===================================================================
--- liboggz/trunk/src/liboggz/oggz_write.c	2007-12-07 21:49:31 UTC (rev 3302)
+++ liboggz/trunk/src/liboggz/oggz_write.c	2007-12-07 21:54:24 UTC (rev 3303)
@@ -651,6 +651,10 @@
   if (writer->writing) return OGGZ_ERR_RECURSIVE_WRITE;
   writer->writing = 1;
 
+#ifdef DEBUG
+  printf ("oggz_write_output: IN\n");
+#endif
+
   if ((cb_ret = oggz->cb_next) != OGGZ_CONTINUE) {
     oggz->cb_next = 0;
     writer->writing = 0;
@@ -662,16 +666,28 @@
   while (active && remaining > 0) {
     bytes = MIN (remaining, 1024);
 
+#ifdef DEBUG
+    printf ("oggz_write_output: write loop (%ld , %ld remain) ...\n", bytes,
+	    remaining);
+#endif
+
     while (writer->state == OGGZ_MAKING_PACKETS) {
+#ifdef DEBUG
+      	printf ("oggz_write_output: MAKING_PACKETS\n");
+#endif
       if ((cb_ret = oggz_writer_make_packet (oggz)) != OGGZ_CONTINUE) {
+#ifdef DEBUG
+        printf ("oggz_write_output: no packets (cb_ret is %d)\n", cb_ret);
+#endif
         if (cb_ret == OGGZ_WRITE_EMPTY) {
           writer->flushing = 1;
           writer->no_more_packets = 1;
-          cb_ret = OGGZ_CONTINUE;
-        } else {
-          active = 0;
-          break;
         }
+        /* At this point, in contrast to oggz_write(), we break out of this
+         * loop unconditionally.
+         */
+        active = 0;
+        break;
       }
       if (oggz_page_init (oggz)) {
         writer->state = OGGZ_WRITING_PAGES;
@@ -689,6 +705,9 @@
           active = 0;
           break;
         } else if (!oggz_page_init (oggz)) {
+#ifdef DEBUG
+          printf ("oggz_write_output: bytes_written == 0, DONE\n");
+#endif
           writer->state = OGGZ_MAKING_PACKETS;
         }
       }
@@ -700,6 +719,10 @@
     }
   }
 
+#ifdef DEBUG
+  printf ("oggz_write_output: OUT %ld\n", nwritten);
+#endif
+
   writer->writing = 0;
 
   if (nwritten == 0) {
@@ -753,7 +776,7 @@
     while (writer->state == OGGZ_MAKING_PACKETS) {
       if ((cb_ret = oggz_writer_make_packet (oggz)) != OGGZ_CONTINUE) {
 #ifdef DEBUG
-      	printf ("oggz_write: no packets (cb_ret is %d)\n", cb_ret);
+        printf ("oggz_write: no packets (cb_ret is %d)\n", cb_ret);
 #endif
         /*
          * if we're out of packets because we're at the end of the file,



More information about the commits mailing list