mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-20 06:59:53 -05:00
make O_CLOEXEC, O_NONBLOCK and socket low latency fd ops more uniform: always return void, name them similarly, only pass a single fd
git-svn-id: file:///home/lennart/svn/public/pulseaudio/branches/lennart@1867 fefdeb5f-60dc-0310-8127-8f9354f1896f
This commit is contained in:
parent
0fcad97782
commit
75f799a3d8
16 changed files with 105 additions and 123 deletions
|
|
@ -143,83 +143,64 @@ void pa_socket_peer_to_string(int fd, char *c, size_t l) {
|
|||
pa_snprintf(c, l, "Unknown client");
|
||||
}
|
||||
|
||||
int pa_socket_low_delay(int fd) {
|
||||
void pa_make_socket_low_delay(int fd) {
|
||||
|
||||
#ifdef SO_PRIORITY
|
||||
int priority;
|
||||
pa_assert(fd >= 0);
|
||||
|
||||
priority = 6;
|
||||
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;
|
||||
}
|
||||
|
||||
int pa_socket_tcp_low_delay(int fd) {
|
||||
int ret, tos, on;
|
||||
|
||||
void pa_make_tcp_socket_low_delay(int fd) {
|
||||
pa_assert(fd >= 0);
|
||||
|
||||
ret = pa_socket_low_delay(fd);
|
||||
|
||||
on = 1;
|
||||
tos = 0;
|
||||
|
||||
pa_make_socket_low_delay(fd);
|
||||
|
||||
#if defined(SOL_TCP) || defined(IPPROTO_TCP)
|
||||
{
|
||||
int on = 1;
|
||||
#if defined(SOL_TCP)
|
||||
if (setsockopt(fd, SOL_TCP, TCP_NODELAY, (void*)&on, sizeof(on)) < 0)
|
||||
if (setsockopt(fd, SOL_TCP, TCP_NODELAY, (void*)&on, sizeof(on)) < 0)
|
||||
#else
|
||||
if (setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, (void*)&on, sizeof(on)) < 0)
|
||||
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;
|
||||
pa_log_warn("TCP_NODELAY failed: %s", pa_cstrerror(errno));
|
||||
}
|
||||
#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;
|
||||
int 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));
|
||||
}
|
||||
#endif
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int pa_socket_udp_low_delay(int fd) {
|
||||
int ret, tos;
|
||||
|
||||
void pa_make_udp_socket_low_delay(int fd) {
|
||||
pa_assert(fd >= 0);
|
||||
|
||||
ret = pa_socket_low_delay(fd);
|
||||
|
||||
tos = 0;
|
||||
|
||||
|
||||
pa_make_socket_low_delay(fd);
|
||||
|
||||
#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
|
||||
{
|
||||
ret = -1;
|
||||
pa_log_warn("IP_TOS failed: %s", pa_cstrerror(errno));
|
||||
int 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));
|
||||
}
|
||||
#endif
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int pa_socket_set_rcvbuf(int fd, size_t l) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue