Commit a20f85ef authored by Joanne Hugé's avatar Joanne Hugé

Add socket option for timestamps

parent 3d857a59
......@@ -54,7 +54,7 @@ static size_t tx_buffer_len = sizeof(tx_buffer);
static int fd;
static int so_timestamping_flags =
SOF_TIMESTAMPING_RX_SOFTWARE | SOF_TIMESTAMPING_TX_SOFTWARE;
SOF_TIMESTAMPING_RX_SOFTWARE | SOF_TIMESTAMPING_TX_SOFTWARE | SOF_TIMESTAMPING_SOFTWARE | SOF_TIMESTAMPING_RAW_HARDWARE;
// Sets the interface
static int set_if(char *network_if) {
......@@ -165,12 +165,15 @@ void send_udp_packet(int use_etf, int use_timestamps, uint64_t txtime,
if (sendmsgerr < 0)
error(EXIT_FAILURE, errno, "sendmsg failed, ret value: %d\n", sendmsgerr);
pollerr = poll(&poll_fd, 1, 0);
// If the poll revents containts a POLLERR flag
if (pollerr == 1 && (poll_fd.revents & POLLERR)) {
process_socket_error_queue(fd);
} else if(use_timestamps) {
process_timestamps(fd);
for(int i = 0; i < (use_timestamps + 1); i++) {
printf("Polling...\n");
pollerr = poll(&poll_fd, 1, 0);
// If the poll revents containts a POLLERR flag
if (pollerr == 1 && (poll_fd.revents & POLLERR)) {
process_socket_error_queue(fd);
} else if(use_timestamps) {
process_timestamps(fd);
}
}
}
......@@ -192,11 +195,12 @@ static void process_timestamps(int sock) {
msg.msg_control = &control;
msg.msg_controllen = sizeof(control);
if (recvmsg(sock, &msg, 0) == -1) {
if (recvmsg(sock, &msg, MSG_DONTWAIT) == -1) {
fprintf(stderr, "recvmsg failed");
exit(EXIT_FAILURE);
}
print_timestamps(&msg);
else {
print_timestamps(&msg);
}
}
/*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment