| 1 | #include <rplay.h> |
| 2 | |
| 3 | static void event_callback(int fd, int event, char *line); |
| 4 | |
| 5 | main(int argc, char **argv) |
| 6 | { |
| 7 | char buf[RPTP_MAX_LINE]; |
| 8 | int fd; |
| 9 | |
| 10 | fd = rptp_open(rplay_default_host(), RPTP_PORT, buf, sizeof(buf)); |
| 11 | rptp_async_notify(fd, RPTP_EVENT_LEVEL | RPTP_EVENT_CLOSE, event_callback); |
| 12 | rptp_main_loop(); |
| 13 | |
| 14 | exit(0); |
| 15 | } |
| 16 | |
| 17 | static void |
| 18 | event_callback(int fd, int event, char *line) |
| 19 | { |
| 20 | static int i; |
| 21 | int left, right; |
| 22 | |
| 23 | switch (event) |
| 24 | { |
| 25 | case RPTP_EVENT_LEVEL: |
| 26 | left = atoi(rptp_parse(line, "left")); |
| 27 | right = atoi(rptp_parse(0, "right")); |
| 28 | printf("%3d %3d\n", left, right); |
| 29 | break; |
| 30 | |
| 31 | case RPTP_EVENT_CLOSE: |
| 32 | exit(0); |
| 33 | } |
| 34 | } |