summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2007-09-18 22:24:45 +0000
committerLennart Poettering <lennart@poettering.net>2007-09-18 22:24:45 +0000
commitf44ddd1052af8026ce3bcb91b377d980a0913445 (patch)
tree645674c1be222b1bef33104beb8beaf6aab68b10
parent6b2fd2328ab715fb5ce4544fc431e545747ca95f (diff)
add new pa_socket_udp_low_delay() API
git-svn-id: file:///home/lennart/svn/public/pulseaudio/branches/lennart@1860 fefdeb5f-60dc-0310-8127-8f9354f1896f
-rw-r--r--src/pulsecore/socket-util.c36
-rw-r--r--src/pulsecore/socket-util.h1
2 files changed, 36 insertions, 1 deletions
diff --git a/src/pulsecore/socket-util.c b/src/pulsecore/socket-util.c
index 4026b9b1..cd912bf0 100644
--- a/src/pulsecore/socket-util.c
+++ b/src/pulsecore/socket-util.c
@@ -144,13 +144,16 @@ void pa_socket_peer_to_string(int fd, char *c, size_t l) {
}
int pa_socket_low_delay(int fd) {
+
#ifdef SO_PRIORITY
int priority;
pa_assert(fd >= 0);
priority = 7;
- if (setsockopt(fd, SOL_SOCKET, SO_PRIORITY, (void*)&priority, sizeof(priority)) < 0)
+ if (setsockopt(fd, SOL_SOCKET, SO_PRIORITY, (void*)&priority, sizeof(priority)) < 0) {
+ pa_log_warn("SO_PRIORITY failed: %s", pa_cstrerror(errno));
return -1;
+ }
#endif
return 0;
@@ -172,9 +175,37 @@ int pa_socket_tcp_low_delay(int fd) {
#else
if (setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, (void*)&on, sizeof(on)) < 0)
#endif
+ {
+ pa_log_warn("TCP_NODELAY failed: %s", pa_cstrerror(errno));
+ ret = -1;
+ }
+#endif
+
+#if defined(IPTOS_LOWDELAY) && defined(IP_TOS) && (defined(SOL_IP) || defined(IPPROTO_IP))
+ tos = IPTOS_LOWDELAY;
+#ifdef SOL_IP
+ if (setsockopt(fd, SOL_IP, IP_TOS, (void*)&tos, sizeof(tos)) < 0)
+#else
+ if (setsockopt(fd, IPPROTO_IP, IP_TOS, (void*)&tos, sizeof(tos)) < 0)
+#endif
+ {
+ pa_log_warn("IP_TOS failed: %s", pa_cstrerror(errno));
ret = -1;
+ }
#endif
+ return ret;
+}
+
+int pa_socket_udp_low_delay(int fd) {
+ int ret, tos;
+
+ pa_assert(fd >= 0);
+
+ ret = pa_socket_low_delay(fd);
+
+ tos = 0;
+
#if defined(IPTOS_LOWDELAY) && defined(IP_TOS) && (defined(SOL_IP) || defined(IPPROTO_IP))
tos = IPTOS_LOWDELAY;
#ifdef SOL_IP
@@ -182,7 +213,10 @@ int pa_socket_tcp_low_delay(int fd) {
#else
if (setsockopt(fd, IPPROTO_IP, IP_TOS, (void*)&tos, sizeof(tos)) < 0)
#endif
+ {
ret = -1;
+ pa_log_warn("IP_TOS failed: %s", pa_cstrerror(errno));
+ }
#endif
return ret;
diff --git a/src/pulsecore/socket-util.h b/src/pulsecore/socket-util.h
index 616c40ac..abe9ce10 100644
--- a/src/pulsecore/socket-util.h
+++ b/src/pulsecore/socket-util.h
@@ -31,6 +31,7 @@ void pa_socket_peer_to_string(int fd, char *c, size_t l);
int pa_socket_low_delay(int fd);
int pa_socket_tcp_low_delay(int fd);
+int pa_socket_udp_low_delay(int fd);
int pa_socket_set_sndbuf(int fd, size_t l);
int pa_socket_set_rcvbuf(int fd, size_t l);