-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.c
67 lines (55 loc) · 1.16 KB
/
main.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include "compat.h"
#include "sound.h"
#include "highlevel.h"
#include "connection_request.h"
#include <pthread.h>
#include <semaphore.h>
#include <errno.h>
#include <string.h>
int sockfd;
struct sockaddr_in * pservaddr;
sem_t * sem_microphone;
void * encode_thread(void * args);
#ifdef __cplusplus
extern "C" {
#endif
int main2() {
struct sockaddr_in servaddr;
pthread_t encoder;
sem_t micro;
int err;
struct connection_request connectme = {
"Machine Youx",
"",
"sllm",
"Client test!",
0
};
audio_init();
err = sem_unlink("microphone");
if(err != 0) {
printf(strerror(errno));
//exit(0);
}
sem_microphone = sem_open("microphone", O_CREAT | O_EXCL, S_IRWXU, 0);
if(sem_microphone == SEM_FAILED) {
printf(strerror(errno));
exit(0);
}
pthread_create(&encoder, NULL, encode_thread, NULL);
connect_to(&connectme, &sockfd, &servaddr);
pservaddr = &servaddr;
//printf("main : sockfd == %i\n", sockfd);
receive(sockfd, &servaddr);
return 0;
}
#ifdef __cplusplus
}
#endif