summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWim Taymans <wim.taymans@gmail.com>2007-08-16 11:49:01 +0000
committerWim Taymans <wim.taymans@gmail.com>2007-08-16 11:49:01 +0000
commit042d3a461c84d4c4ecb232f5eff40e1ce77ac03c (patch)
treeb92f3d9a57de4ce32f161d7d7c545cf2d1181d51
parent41f0496738f42b64868500ebb4be4053a1500f91 (diff)
gst/udp/gstudpsrc.c: Improve UDP performance by avoiding a select() when we have data available immediatly.
Original commit message from CVS: * gst/udp/gstudpsrc.c: (gst_udpsrc_create): Improve UDP performance by avoiding a select() when we have data available immediatly.
-rw-r--r--ChangeLog6
-rw-r--r--gst/udp/gstudpsrc.c13
2 files changed, 17 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 69a5b2da..e5fe5a6e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
2007-08-16 Wim Taymans <wim.taymans@gmail.com>
+ * gst/udp/gstudpsrc.c: (gst_udpsrc_create):
+ Improve UDP performance by avoiding a select() when we have data
+ available immediatly.
+
+2007-08-16 Wim Taymans <wim.taymans@gmail.com>
+
* gst/rtsp/gstrtpdec.c: (gst_rtp_dec_marshal_VOID__UINT_UINT),
(gst_rtp_dec_class_init):
* gst/rtsp/gstrtpdec.h:
diff --git a/gst/udp/gstudpsrc.c b/gst/udp/gstudpsrc.c
index 1c26c56e..5b847b0a 100644
--- a/gst/udp/gstudpsrc.c
+++ b/gst/udp/gstudpsrc.c
@@ -368,6 +368,14 @@ gst_udpsrc_create (GstPushSrc * psrc, GstBuffer ** buf)
udpsrc = GST_UDPSRC (psrc);
+ /* quick check, avoid going in select when we already have data */
+ readsize = 0;
+ if ((ret = IOCTL_SOCKET (udpsrc->sock, FIONREAD, &readsize)) < 0)
+ goto ioctl_failed;
+
+ if (readsize > 0)
+ goto no_select;
+
do {
gboolean stop;
struct timeval timeval, *timeout;
@@ -433,11 +441,12 @@ gst_udpsrc_create (GstPushSrc * psrc, GstBuffer ** buf)
if ((ret = IOCTL_SOCKET (udpsrc->sock, FIONREAD, &readsize)) < 0)
goto ioctl_failed;
- GST_LOG_OBJECT (udpsrc, "ioctl says %d bytes available", (int) readsize);
-
if (!readsize)
goto nothing_to_read;
+no_select:
+ GST_LOG_OBJECT (udpsrc, "ioctl says %d bytes available", (int) readsize);
+
pktdata = g_malloc (readsize);
pktsize = readsize;