[xiph-commits] r3323 - liboggz/trunk/src/liboggz
conrad at svn.annodex.net
conrad at svn.annodex.net
Wed Jan 9 00:58:29 PST 2008
Author: conrad
Date: 2008-01-09 00:58:29 -0800 (Wed, 09 Jan 2008)
New Revision: 3323
Modified:
liboggz/trunk/src/liboggz/oggz_write.c
Log:
Update oggz_write to handle asynchronous feeding of packets and writing, in
light of changes introduced in r3293, r3296. This fixes the bug outlined in
http://lists.xiph.org/pipermail/annodex-dev/2007-December/000217.html
Also the output of anxed has been checked, and produces identical output to
that of r3296 (ie. final pages are still flushed as required).
Modified: liboggz/trunk/src/liboggz/oggz_write.c
===================================================================
--- liboggz/trunk/src/liboggz/oggz_write.c 2008-01-08 00:46:09 UTC (rev 3322)
+++ liboggz/trunk/src/liboggz/oggz_write.c 2008-01-09 08:58:29 UTC (rev 3323)
@@ -324,6 +324,8 @@
return -1;
}
+ writer->no_more_packets = 0;
+
#ifdef DEBUG
printf ("oggz_write_feed: enqueued packet, queue size %d\n",
oggz_vector_size (writer->packet_queue));
@@ -557,17 +559,28 @@
} else {
*next_zpacket = oggz_vector_pop (writer->packet_queue);
-#ifdef DEBUG
- printf ("oggz_dequeue_packet: dequeued packet, queue size %d\n",
- oggz_vector_size (writer->packet_queue));
-#endif
-
if (*next_zpacket == NULL) {
if (writer->hungry) {
ret = writer->hungry (oggz, 1, writer->hungry_user_data);
*next_zpacket = oggz_vector_pop (writer->packet_queue);
+#ifdef DEBUG
+ printf ("oggz_dequeue_packet: called hungry and popped, new queue size %d\n",
+ oggz_vector_size (writer->packet_queue));
+#endif
+
+#ifdef DEBUG
+ } else {
+ printf ("oggz_dequeue_packet: no packet, no hungry, queue size %d\n",
+ oggz_vector_size (writer->packet_queue));
+#endif
}
+#ifdef DEBUG
+ } else {
+ printf ("oggz_dequeue_packet: dequeued packet, queue size %d\n",
+ oggz_vector_size (writer->packet_queue));
+#endif
}
+
}
#ifdef DEBUG
@@ -774,6 +787,9 @@
#endif
while (writer->state == OGGZ_MAKING_PACKETS) {
+#ifdef DEBUG
+ printf ("oggz_write: MAKING PACKETS\n");
+#endif
if ((cb_ret = oggz_writer_make_packet (oggz)) != OGGZ_CONTINUE) {
#ifdef DEBUG
printf ("oggz_write: no packets (cb_ret is %d)\n", cb_ret);
@@ -787,21 +803,38 @@
* the writing code below.
*/
if (cb_ret == OGGZ_WRITE_EMPTY) {
+#ifdef DEBUG
+ printf ("oggz_write: Inferred end of data, forcing a page flush.\n");
+#endif
writer->flushing = 1;
writer->no_more_packets = 1;
cb_ret = OGGZ_CONTINUE;
} else {
+#ifdef DEBUG
+ printf ("oggz_write: Stopped by user callback.\n");
+#endif
active = 0;
break;
}
}
if (oggz_page_init (oggz)) {
writer->state = OGGZ_WRITING_PAGES;
+ } else {
+#ifdef DEBUG
+ printf ("oggz_write: unable to make page...\n");
+#endif
+ if (writer->no_more_packets) {
+ active = 0;
+ break;
+ }
}
}
if (writer->state == OGGZ_WRITING_PAGES) {
bytes_written = oggz_page_writeout (oggz, bytes);
+#ifdef DEBUG
+ printf ("oggz_write: MAKING PAGES; wrote %ld bytes\n", bytes_written);
+#endif
if (bytes_written == -1) {
active = 0;
More information about the commits
mailing list