Commit f377b0d2 authored by Michael Smith's avatar Michael Smith

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.

svn path=/trunk/vorbis-tools/; revision=3905
parent 53b91094
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* *
* Comment editing backend, suitable for use by nice frontend interfaces. * 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> #include <stdio.h>
...@@ -199,6 +199,7 @@ int vcedit_open_callbacks(vcedit_state *state, void *in, ...@@ -199,6 +199,7 @@ int vcedit_open_callbacks(vcedit_state *state, void *in,
char *buffer; char *buffer;
int bytes,i; int bytes,i;
int chunks = 0;
ogg_packet *header; ogg_packet *header;
ogg_packet header_main; ogg_packet header_main;
ogg_packet header_comments; ogg_packet header_comments;
...@@ -212,19 +213,25 @@ int vcedit_open_callbacks(vcedit_state *state, void *in, ...@@ -212,19 +213,25 @@ int vcedit_open_callbacks(vcedit_state *state, void *in,
state->oy = malloc(sizeof(ogg_sync_state)); state->oy = malloc(sizeof(ogg_sync_state));
ogg_sync_init(state->oy); ogg_sync_init(state->oy);
buffer = ogg_sync_buffer(state->oy, CHUNKSIZE); while(1)
bytes = state->read(buffer, 1, CHUNKSIZE, state->in); {
buffer = ogg_sync_buffer(state->oy, CHUNKSIZE);
bytes = state->read(buffer, 1, CHUNKSIZE, state->in);
ogg_sync_wrote(state->oy, bytes); ogg_sync_wrote(state->oy, bytes);
if(ogg_sync_pageout(state->oy, &og) != 1) if(ogg_sync_pageout(state->oy, &og) == 1)
{ break;
if(bytes<CHUNKSIZE)
state->lasterror = _("Input truncated or empty."); if(chunks++ >= 10) /* Bail if we don't find data in the first 40 kB */
else {
state->lasterror = _("Input is not an Ogg bitstream."); if(bytes<CHUNKSIZE)
goto err; state->lasterror = _("Input truncated or empty.");
} else
state->lasterror = _("Input is not an Ogg bitstream.");
goto err;
}
}
state->serial = ogg_page_serialno(&og); state->serial = ogg_page_serialno(&og);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment