[rtmpdump] r477 - in trunk/librtmp: rtmp.c rtmp_sys.h

hyc subversion at mplayerhq.hu
Tue May 11 05:49:28 CEST 2010


Author: hyc
Date: Tue May 11 05:49:27 2010
New Revision: 477

Log:
Fix RTMP_Read, return 0 on EOF, not -1

Modified:
   trunk/librtmp/rtmp.c
   trunk/librtmp/rtmp_sys.h

Modified: trunk/librtmp/rtmp.c
==============================================================================
--- trunk/librtmp/rtmp.c	Tue May 11 05:30:32 2010	(r476)
+++ trunk/librtmp/rtmp.c	Tue May 11 05:49:27 2010	(r477)
@@ -4039,8 +4039,17 @@ RTMP_Read(RTMP *r, char *buf, int size)
   int nRead = 0, total = 0;
 
   /* can't continue */
-  if (r->m_read.status < 0)
+fail:
+  switch (r->m_read.status < 0) {
+  case RTMP_READ_EOF:
+  case RTMP_READ_COMPLETE:
+    return 0;
+  case RTMP_READ_ERROR:  /* corrupted stream, resume failed */
+    SetSockError(EINVAL);
     return -1;
+  default:
+    break;
+  }
 
   /* first time thru */
   if (!(r->m_read.flags & RTMP_READ_HEADER))
@@ -4064,7 +4073,7 @@ RTMP_Read(RTMP *r, char *buf, int size)
 		  r->m_read.buf = NULL;
 		  r->m_read.buflen = 0;
 		  r->m_read.status = nRead;
-		  return -1;
+		  goto fail;
 		}
 	      r->m_read.buf += nRead;
 	      r->m_read.buflen -= nRead;

Modified: trunk/librtmp/rtmp_sys.h
==============================================================================
--- trunk/librtmp/rtmp_sys.h	Tue May 11 05:30:32 2010	(r476)
+++ trunk/librtmp/rtmp_sys.h	Tue May 11 05:49:27 2010	(r477)
@@ -37,6 +37,7 @@
 #endif
 
 #define GetSockError()	WSAGetLastError()
+#define SetSockError(e)	WSASetLastError(e)
 #define setsockopt(a,b,c,d,e)	(setsockopt)(a,b,c,(const char *)d,(int)e)
 #define EWOULDBLOCK	WSAETIMEDOUT	/* we don't use nonblocking, but we do use timeouts */
 #define sleep(n)	Sleep(n*1000)
@@ -52,6 +53,7 @@
 #include <netinet/in.h>
 #include <netinet/tcp.h>
 #define GetSockError()	errno
+#define SetSockError(e)	errno = e
 #undef closesocket
 #define closesocket(s)	close(s)
 #define msleep(n)	usleep(n*1000)


More information about the rtmpdump mailing list