[NUT-devel] [nut]: r238 - trunk/libnut/demuxer.c

ods15 subversion at mplayerhq.hu
Sat Nov 18 15:44:12 CET 2006


Author: ods15
Date: Sat Nov 18 15:44:12 2006
New Revision: 238

Modified:
   trunk/libnut/demuxer.c

Log:
add a last resort in main header search - not stop search at syncpoints


Modified: trunk/libnut/demuxer.c
==============================================================================
--- trunk/libnut/demuxer.c	(original)
+++ trunk/libnut/demuxer.c	Sat Nov 18 15:44:12 2006
@@ -726,7 +726,7 @@
 		tmp = (tmp << 8) | *(nut->i->buf_ptr++);
 		if (tmp == MAIN_STARTCODE) break;
 		// give up if we reach a syncpoint, unless we're searching the file end
-		if (tmp == SYNCPOINT_STARTCODE && nut->seek_status != 18) break;
+		if (tmp == SYNCPOINT_STARTCODE && nut->seek_status != 18 && !nut->last_syncpoint) break;
 	}
 	if (tmp == MAIN_STARTCODE) {
 		off_t pos = bctello(nut->i) - 8;
@@ -741,7 +741,7 @@
 			ERROR(err, err); // if get_bytes returns EAGAIN or a memory error, check for that
 		} while (tmp != SYNCPOINT_STARTCODE);
 		if (tmp == SYNCPOINT_STARTCODE) { // success!
-			nut->before_seek = nut->seek_status = 0;
+			nut->last_syncpoint = nut->before_seek = nut->seek_status = 0;
 			nut->last_headers = pos;
 			nut->i->buf_ptr = get_buf(nut->i, nut->last_headers);
 			flush_buf(nut->i);
@@ -766,6 +766,13 @@
 	// evantually we'll hit EOF and give up
 	return find_main_headers(nut);
 err_out:
+	if (err == NUT_ERR_EOF && !nut->last_syncpoint && nut->seek_status) {
+		// last resort: after checking whole file, try again, this time don't stop at syncpoints.
+		nut->last_syncpoint = 1;
+		nut->before_seek = nut->seek_status = 0;
+		seek_buf(nut->i, 0, SEEK_SET);
+		return find_main_headers(nut);
+	}
 	return err;
 }
 



More information about the NUT-devel mailing list