diff options
Diffstat (limited to 'serve_image.c')
-rw-r--r-- | serve_image.c | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/serve_image.c b/serve_image.c index f7f6315..38549a1 100644 --- a/serve_image.c +++ b/serve_image.c @@ -2,13 +2,13 @@ #define _POSIX_C_SOURCE 199309 #include <time.h> -#include <errno.h> -#include <error.h> -#include <netdb.h> -#include <stdio.h> -#include <stdlib.h> +#include <errno.h> +#include <error.h> +#include <netdb.h> +#include <stdio.h> +#include <stdlib.h> #include <string.h> -#include <unistd.h> +#include <unistd.h> #include <fcntl.h> #include <sys/types.h> #include <sys/stat.h> @@ -83,7 +83,7 @@ int main(int argc, char **argv) fprintf(stderr, "Failed to allocate last-block buffer\n"); exit(1); } - + fec = fec_new(pkts_per_block, total_pkts_per_block); if (!fec) { fprintf(stderr, "Error initialising FEC\n"); @@ -93,7 +93,7 @@ int main(int argc, char **argv) memset(&hints, 0, sizeof(hints)); hints.ai_flags = AI_ADDRCONFIG; hints.ai_socktype = SOCK_DGRAM; - + ret = getaddrinfo(argv[1], argv[2], &hints, &ai); if (ret) { fprintf(stderr, "getaddrinfo: %s\n", gai_strerror(ret)); @@ -167,9 +167,9 @@ int main(int argc, char **argv) fflush(stdout); block_crcs[block_nr] = mtd_crc32(-1, image + (block_nr * erasesize), erasesize); } - + printf("\nImage size %ld KiB (0x%08lx). %d blocks at %d pkts/block\n" - "Estimated transmit time per cycle: %ds\n", + "Estimated transmit time per cycle: %ds\n", (long)st.st_size / 1024, (long) st.st_size, nr_blocks, pkts_per_block, nr_blocks * pkts_per_block * pkt_delay / 1000000); @@ -202,11 +202,11 @@ int main(int argc, char **argv) the first $pkts_per_block are cheap enough though because they're just copies. So alternate between simple and complex stuff, so that we don't start - to choke and fail to keep up with the expected + to choke and fail to keep up with the expected bitrate in the second half of the sequence */ if (block_nr & 1) actualpkt = pkt_nr; - else + else actualpkt = total_pkts_per_block - 1 - pkt_nr; blockptr = image + (erasesize * block_nr); @@ -246,7 +246,7 @@ int main(int argc, char **argv) #endif gettimeofday(&now, NULL); #if 1 - tosleep = nextpkt.tv_usec - now.tv_usec + + tosleep = nextpkt.tv_usec - now.tv_usec + (1000000 * (nextpkt.tv_sec - now.tv_sec)); /* We need hrtimers for this to actually work */ @@ -276,7 +276,7 @@ int main(int argc, char **argv) Adjust our expected timings accordingly. If we're only a little way behind, don't slip yet */ if (now.tv_usec > (now.tv_usec + (5 * pkt_delay) + - 1000000 * (nextpkt.tv_sec - now.tv_sec))) { + 1000000 * (nextpkt.tv_sec - now.tv_sec))) { nextpkt = now; } @@ -291,7 +291,7 @@ int main(int argc, char **argv) writeerrors = 0; - + } } munmap(image, st.st_size); |