-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathhdjd.c
69 lines (55 loc) · 1013 Bytes
/
hdjd.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
68
69
#include <signal.h>
#include <stdio.h>
#include <stdint.h>
#include <sys/select.h>
#include "alsa.h"
#include "usb.h"
#include "dump.h"
static volatile int keepRunning = 1;
void intHandler(int dummy) {
keepRunning = 0;
usb_interrupting();
alsa_interrupting();
}
int
setup()
{
char name[100];
if (usb_setup(name, sizeof(name)) < 0) {
usb_finish();
return -1;
}
if (alsa_setup(name) < 0) {
alsa_close();
return -1;
}
return 0;
}
int
main(int argc, char *argv[])
{
if (setup() < 0) {
return 69;
}
signal(SIGINT, intHandler);
while (keepRunning) {
fd_set rfds;
fd_set wfds;
int nfds = 0;
int ret;
FD_ZERO(&rfds);
FD_ZERO(&wfds);
alsa_fd_setup(&nfds, &rfds, &wfds);
usb_fd_setup(&nfds, &rfds, &wfds);
ret = select(nfds + 1, &rfds, &wfds, NULL, NULL);
if (-1 == ret) {
DUMP();
}
alsa_check_fds(&rfds, &wfds);
usb_check_fds(&rfds, &wfds);
}
printf("Exiting...\n");
usb_finish();
alsa_close();
return 0;
}