]> git.keenfalcon.ru Git - fpvtools.git/commitdiff
opt_s optimization master
authorLelik P. Korchagin <lelik@korchagins.ru>
Tue, 31 Oct 2023 16:38:56 +0000 (19:38 +0300)
committerLelik P. Korchagin <lelik@korchagins.ru>
Tue, 31 Oct 2023 16:38:56 +0000 (19:38 +0300)
fpvplay.c

index 1a1e397965c2c5733feacb50c3e4704041a94379..cffc9132915c0a305ff342b8c8cc5ad9277fd8f1 100644 (file)
--- a/fpvplay.c
+++ b/fpvplay.c
@@ -139,7 +139,6 @@ int main(int argc, char *argv[])
 
         for (int i = 0; (optind + i) < argc; i++) {
                 int file = open(argv[optind + i], O_RDONLY);
-                int play = 0;
                 int ms = 0;
 
                 if (file < 0) {
@@ -148,12 +147,14 @@ int main(int argc, char *argv[])
 
                 while (1) {
                         static struct flight_data_record r; // flight_data_record is too large to be allocated ot the top of the stack !!!
+                        int sleep;
 
                         if (get_record(file, &r) < 0) {
                                 break;
                         }
 
                         if (opt_s > 0 && r.ms < opt_s) {
+                                ms = r.ms;
                                 continue;
                         }
 
@@ -161,11 +162,8 @@ int main(int argc, char *argv[])
                                 break;
                         }
 
-                        if (play) {
-                                int sleep = r.ms - ms;
-                                if (sleep > 0) {
-                                        usleep(sleep * 1000);
-                                }
+                        if ((sleep = r.ms - ms) > 0) {
+                                usleep(sleep * 1000);
                         }
                         ms = r.ms;