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

Michael Smith msmith at xiph.org
Thu Sep 12 05:48:27 PDT 2002



msmith      02/09/12 08:48:27

  Modified:    vorbiscomment vcedit.c
  Log:
  Try harder at start-of-file to find valid ogg data before giving up. This
  allows vorbiscomment to cope with ID3V2 data incorrectly inserted at the
  start of the file.

Revision  Changes    Path
1.22      +21 -14    vorbis-tools/vorbiscomment/vcedit.c

Index: vcedit.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis-tools/vorbiscomment/vcedit.c,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -r1.21 -r1.22
--- vcedit.c	12 Sep 2002 12:41:52 -0000	1.21
+++ vcedit.c	12 Sep 2002 12:48:27 -0000	1.22
@@ -6,7 +6,7 @@
  *
  * Comment editing backend, suitable for use by nice frontend interfaces.
  *
- * last modified: $Id: vcedit.c,v 1.21 2002/09/12 12:41:52 msmith Exp $
+ * last modified: $Id: vcedit.c,v 1.22 2002/09/12 12:48:27 msmith Exp $
  */
 
 #include <stdio.h>
@@ -199,6 +199,7 @@
 
         char *buffer;
         int bytes,i;
+    int chunks = 0;
         ogg_packet *header;
         ogg_packet	header_main;
         ogg_packet  header_comments;
@@ -212,19 +213,25 @@
         state->oy = malloc(sizeof(ogg_sync_state));
         ogg_sync_init(state->oy);
 
-	buffer = ogg_sync_buffer(state->oy, CHUNKSIZE);
-	bytes = state->read(buffer, 1, CHUNKSIZE, state->in);
-
-	ogg_sync_wrote(state->oy, bytes);
-
-	if(ogg_sync_pageout(state->oy, &og) != 1)
-	{
-		if(bytes<CHUNKSIZE)
-			state->lasterror = _("Input truncated or empty.");
-		else
-			state->lasterror = _("Input is not an Ogg bitstream.");
-		goto err;
-	}
+    while(1)
+    {
+    	buffer = ogg_sync_buffer(state->oy, CHUNKSIZE);
+	    bytes = state->read(buffer, 1, CHUNKSIZE, state->in);
+
+    	ogg_sync_wrote(state->oy, bytes);
+
+        if(ogg_sync_pageout(state->oy, &og) == 1)
+            break;
+
+        if(chunks++ >= 10) /* Bail if we don't find data in the first 40 kB */
+        {
+		    if(bytes<CHUNKSIZE)
+			    state->lasterror = _("Input truncated or empty.");
+    		else
+	    		state->lasterror = _("Input is not an Ogg bitstream.");
+		    goto err;
+    	}
+    }
 
         state->serial = ogg_page_serialno(&og);
 

<p><p>--- >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