Author: adrian
Date: Tue Apr  5 14:09:14 2011
New Revision: 9407

URL: http://svn.slimdevices.com/jive?rev=9407&view=rev
Log:
Bug: N/A
Description: C code to support higher speed network tests using streaming code 
rather than slimproto

Modified:
    7.6/trunk/squeezeplay/src/squeezeplay/src/audio/streambuf.c

Modified: 7.6/trunk/squeezeplay/src/squeezeplay/src/audio/streambuf.c
URL: 
http://svn.slimdevices.com/jive/7.6/trunk/squeezeplay/src/squeezeplay/src/audio/streambuf.c?rev=9407&r1=9406&r2=9407&view=diff
==============================================================================
--- 7.6/trunk/squeezeplay/src/squeezeplay/src/audio/streambuf.c (original)
+++ 7.6/trunk/squeezeplay/src/squeezeplay/src/audio/streambuf.c Tue Apr  5 
14:09:14 2011
@@ -787,6 +787,37 @@
 }
 
 
+/* read bytes from the streaming socket and discard - used by network test to 
measure network throughput*/
+static int stream_readtonullL(lua_State *L) {
+       struct stream *stream;
+       char buf[4094];
+       int n;
+       /*
+        * 1: Stream (self)
+        */
+
+       stream = lua_touserdata(L, 1);
+
+       n = recv(stream->fd, buf, sizeof(buf), 0);      
+
+       if (n > 0) {
+               fifo_lock(&streambuf_fifo);
+               streambuf_bytes_received += n;
+               fifo_unlock(&streambuf_fifo);
+               lua_pushinteger(L, n);
+               return 1;
+       } else if (n == -1 && errno == EAGAIN) {
+               lua_pushinteger(L, 0);
+               return 1;
+       } else {
+               CLOSESOCKET(stream->fd);
+               lua_pushnil(L);
+               lua_pushstring(L, strerror(n));
+               return 2;
+       }
+}
+
+
 static int stream_setstreamingL(lua_State *L) {
        /*
         * 1: Stream (self)
@@ -845,6 +876,7 @@
        { "write", stream_writeL },
        { "feedFromLua", stream_feedfromL },
        { "readToLua", stream_readtoL },
+       { "readToNull", stream_readtonullL },
        { "setStreaming", stream_setstreamingL },
        { NULL, NULL }
 };

_______________________________________________
Jive-checkins mailing list
[email protected]
http://lists.slimdevices.com/mailman/listinfo/jive-checkins

Reply via email to