[xiph-cvs] cvs commit: vorbis-tools/vorbiscomment vcedit.c vcedit.h

Michael Smith msmith at xiph.org
Sat Aug 11 22:02:28 PDT 2001



msmith      01/08/11 22:02:28

  Modified:    vorbiscomment vcedit.c vcedit.h
  Log:
  Fix another case which mostly occurs with slightly broken streams.

Revision  Changes    Path
1.12      +32 -27    vorbis-tools/vorbiscomment/vcedit.c

Index: vcedit.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis-tools/vorbiscomment/vcedit.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- vcedit.c	2001/08/11 14:59:07	1.11
+++ vcedit.c	2001/08/12 05:02:27	1.12
@@ -6,7 +6,7 @@
  *
  * Comment editing backend, suitable for use by nice frontend interfaces.
  *
- * last modified: $Id: vcedit.c,v 1.11 2001/08/11 14:59:07 msmith Exp $
+ * last modified: $Id: vcedit.c,v 1.12 2001/08/12 05:02:27 msmith Exp $
  */
 
 #include <stdio.h>
@@ -90,10 +90,7 @@
         char *buffer;
         int bytes;
 
-	if(p)
-		result = ogg_stream_packetout(s->os, p);
-	else
-		result = ogg_stream_packetpeek(s->os, NULL);
+	result = ogg_stream_packetout(s->os, p);
 
         if(result > 0)
                 return 1;
@@ -106,8 +103,6 @@
                         ogg_sync_wrote(s->oy, bytes);
                         if(bytes == 0) 
                                 return 0;
-			else if(bytes < CHUNKSIZE)
-				s->eof=1;
                 }
 
                 ogg_stream_pagein(s->os, &og);
@@ -249,6 +244,7 @@
         int result;
         char *buffer;
         int bytes, eosin=0;
+	int needflush=0, needout=0;
 
         header_main.bytes = state->mainlen;
         header_main.packet = state->mainbuf;
@@ -285,9 +281,33 @@
                 int size;
                 size = _blocksize(state, &op);
                 granpos += size;
+
+		if(needflush)
+		{
+			if(ogg_stream_flush(&streamout, &ogout))
+			{
+				if(state->write(ogout.header,1,ogout.header_len, 
+							out) != (size_t) ogout.header_len)
+					goto cleanup;
+				if(state->write(ogout.body,1,ogout.body_len, 
+							out) != (size_t) ogout.body_len)
+					goto cleanup;
+			}
+		}
+		else if(needout)
+		{
+			if(ogg_stream_pageout(&streamout, &ogout))
+			{
+				if(state->write(ogout.header,1,ogout.header_len, 
+							out) != (size_t) ogout.header_len)
+					goto cleanup;
+				if(state->write(ogout.body,1,ogout.body_len, 
+							out) != (size_t) ogout.body_len)
+					goto cleanup;
+			}
+		}
 
-		if(state->eof && ogg_stream_packetpeek(state->os, NULL) <= 0)
-			op.e_o_s = 1;
+		needflush=needout=0;
 
                 if(op.granulepos == -1)
                 {
@@ -301,32 +321,17 @@
                         {
                                 granpos = op.granulepos;
                                 ogg_stream_packetin(&streamout, &op);
-				if(ogg_stream_flush(&streamout, &ogout))
-				{
-					if(state->write(ogout.header,1,ogout.header_len, 
-								out) != (size_t) ogout.header_len)
-						goto cleanup;
-					if(state->write(ogout.body,1,ogout.body_len, 
-								out) != (size_t) ogout.body_len)
-						goto cleanup;
-				}
+				needflush=1;
                         }
                         else 
                         {
                                 ogg_stream_packetin(&streamout, &op);
-				if(ogg_stream_pageout(&streamout, &ogout))
-				{
-					if(state->write(ogout.header,1,ogout.header_len, 
-								out) != (size_t) ogout.header_len)
-						goto cleanup;
-					if(state->write(ogout.body,1,ogout.body_len, 
-								out) != (size_t) ogout.body_len)
-						goto cleanup;
-				}
+				needout=1;
                         }
                 }		
         }
 
+	streamout.e_o_s = 1;
         while(ogg_stream_flush(&streamout, &ogout))
         {
                 if(state->write(ogout.header,1,ogout.header_len, 

1.7       +0 -1      vorbis-tools/vorbiscomment/vcedit.h

Index: vcedit.h
===================================================================
RCS file: /usr/local/cvsroot/vorbis-tools/vorbiscomment/vcedit.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- vcedit.h	2001/08/11 14:59:08	1.6
+++ vcedit.h	2001/08/12 05:02:27	1.7
@@ -40,7 +40,6 @@
         int		booklen;
         char 	    *lasterror;
         int prevW;
-	int eof;
 } vcedit_state;
 
 extern vcedit_state *	vcedit_new_state(void);

--- >8 ----
List archives:  http://www.xiph.org/archives/
Ogg project homepage: http://www.xiph.org/ogg/
To unsubscribe from this list, send a message to 'cvs-request at xiph.org'
containing only the word 'unsubscribe' in the body.  No subject is needed.
Unsubscribe messages sent to the list will be ignored/filtered.



More information about the commits mailing list