[Redbutton-devel] SF.net SVN: redbutton: [161] redbutton-browser/trunk/mpegts.c
Brought to you by:
skilvington
|
From: <ski...@us...> - 2006-12-18 16:09:26
|
Revision: 161
http://svn.sourceforge.net/redbutton/?rev=161&view=rev
Author: skilvington
Date: 2006-12-18 08:09:23 -0800 (Mon, 18 Dec 2006)
Log Message:
-----------
allow reading less than TS_PACKET_SIZE bytes in one go
Modified Paths:
--------------
redbutton-browser/trunk/mpegts.c
Modified: redbutton-browser/trunk/mpegts.c
===================================================================
--- redbutton-browser/trunk/mpegts.c 2006-12-15 17:11:53 UTC (rev 160)
+++ redbutton-browser/trunk/mpegts.c 2006-12-18 16:09:23 UTC (rev 161)
@@ -236,19 +236,21 @@
/* find the next sync byte */
resync = 0;
nread = 0;
+ *buf = 0;
do
{
/* read the whole of the next packet */
while(nread != TS_PACKET_SIZE && !feof(ts))
nread += fread(buf + nread, 1, TS_PACKET_SIZE - nread, ts);
- if(*buf != TS_SYNC_BYTE && !feof(ts))
+ if(nread > 0 && *buf != TS_SYNC_BYTE && !feof(ts))
{
resync ++;
- memmove(buf, buf + 1, TS_PACKET_SIZE - 1);
- nread = TS_PACKET_SIZE - 1;
+ memmove(buf, buf + 1, nread - 1);
+ buf[nread - 1] = 0;
+ nread --;
}
}
- while(*buf != TS_SYNC_BYTE && !feof(ts));
+ while(nread < TS_PACKET_SIZE && *buf != TS_SYNC_BYTE && !feof(ts));
if(feof(ts))
return -1;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|