From 961fb4466a9396a11f1a9a6e7d4193409b8949d6 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Wed, 30 Jun 2004 00:00:52 +0000 Subject: latency esound volume changing git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@43 fefdeb5f-60dc-0310-8127-8f9354f1896f --- src/util.c | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) (limited to 'src/util.c') diff --git a/src/util.c b/src/util.c index 95350421..8f444336 100644 --- a/src/util.c +++ b/src/util.c @@ -7,6 +7,8 @@ #include #include #include +#include +#include #include "util.h" @@ -83,3 +85,42 @@ fail: rmdir(dir); return -1; } + +int make_socket_low_delay(int fd) { + int ret = 0, buf_size, priority; + + assert(fd >= 0); + + buf_size = 1024; + if (setsockopt(fd, SOL_SOCKET, SO_SNDBUF, &buf_size, sizeof(buf_size)) < 0) + ret = -1; + + buf_size = 1024; + if (setsockopt(fd, SOL_SOCKET, SO_RCVBUF, &buf_size, sizeof(buf_size)) < 0) + ret = -1; + + priority = 7; + if (setsockopt(fd, SOL_SOCKET, SO_PRIORITY, &priority, sizeof(priority)) < 0) + ret = -1; + + return ret; +} + +int make_tcp_socket_low_delay(int fd) { + int ret, tos, on; + + assert(fd >= 0); + + ret = make_socket_low_delay(fd); + + on = 1; + if (setsockopt(fd, SOL_TCP, TCP_NODELAY, &on, sizeof(on)) < 0) + ret = -1; + + tos = IPTOS_LOWDELAY; + if (setsockopt(fd, SOL_IP, IP_TOS, &tos, sizeof(tos)) < 0) + ret = -1; + + return ret; + +} -- cgit