updated
This commit is contained in:
parent
70208183bb
commit
56c5256973
11
LICENSE
11
LICENSE
@ -1,11 +0,0 @@
|
|||||||
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
|
|
||||||
Version 2, December 2004
|
|
||||||
|
|
||||||
Copyright (C) 2004 Sam Hocevar <sam@hocevar.net>
|
|
||||||
|
|
||||||
Everyone is permitted to copy and distribute verbatim or modified copies of this license document, and changing it is allowed as long as the name is changed.
|
|
||||||
|
|
||||||
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
|
|
||||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
|
||||||
|
|
||||||
0. You just DO WHAT THE FUCK YOU WANT TO.
|
|
@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
|
|
||||||
#Record audio in sterio
|
#Record audio in sterio
|
||||||
arecord -D loopout -f S16_LE -t raw -r 41000 -c 2 | ./server
|
arecord -D loopout --buffer-size=20000 -f S16_LE -t raw -r 48000 -c 2 | ./server
|
||||||
|
|
||||||
|
|
||||||
#Geting raw pcm data and send to speaker
|
#Geting raw pcm data and send to speaker
|
||||||
echo "JOIN" | nc -u server_ip server_port | aplay -r 41000 -f S16_LE -c 2
|
echo "JOIN" | nc -u server_ip server_port | aplay -r 48000 -f S16_LE -c 2
|
||||||
|
9
server.c
9
server.c
@ -10,8 +10,8 @@
|
|||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
|
|
||||||
#define PORT 8889
|
#define PORT 8889
|
||||||
#define BUFF_SIZE 3024
|
#define BUFF_SIZE 8192
|
||||||
#define MAX_CLIENTS 25
|
#define MAX_CLIENTS 125
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int fd;
|
int fd;
|
||||||
@ -20,14 +20,13 @@ typedef struct {
|
|||||||
|
|
||||||
void *process_clients(void *p) {
|
void *process_clients(void *p) {
|
||||||
DATA *data = (DATA *)p;
|
DATA *data = (DATA *)p;
|
||||||
char buf[BUFF_SIZE + 1];
|
char buf[BUFF_SIZE];
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
off_t ret = read(STDIN_FILENO, buf, sizeof(buf));
|
off_t ret = read(STDIN_FILENO, buf, sizeof(buf));
|
||||||
if (ret <= 0)
|
if (ret <= 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
buf[ret - 1] = '\0';
|
|
||||||
socklen_t len = sizeof(struct sockaddr_in);
|
socklen_t len = sizeof(struct sockaddr_in);
|
||||||
for (size_t i = 0; i < MAX_CLIENTS; i++)
|
for (size_t i = 0; i < MAX_CLIENTS; i++)
|
||||||
sendto(data->fd, buf, ret, 0, (struct sockaddr *)&data->clients[i], len);
|
sendto(data->fd, buf, ret, 0, (struct sockaddr *)&data->clients[i], len);
|
||||||
@ -41,7 +40,7 @@ int main(void) {
|
|||||||
if (fd < 0)
|
if (fd < 0)
|
||||||
goto ERROR_WITHOUTCLOSE;
|
goto ERROR_WITHOUTCLOSE;
|
||||||
|
|
||||||
struct timeval tv = {.tv_sec = 0, .tv_usec = 512};
|
struct timeval tv = {.tv_sec = 0, .tv_usec = 50};
|
||||||
if (setsockopt(fd, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(tv)) < 0)
|
if (setsockopt(fd, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(tv)) < 0)
|
||||||
goto ERROR;
|
goto ERROR;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user