diff options
author | Lasse Flygenring-Harrsen <Lasse@Flygenring-Harrsen.com> | 2020-07-09 00:44:08 +0200 |
---|---|---|
committer | Lasse Flygenring-Harrsen <Lasse@Flygenring-Harrsen.com> | 2020-07-09 00:44:08 +0200 |
commit | 58a42a627ca6e51f71adfec3ab2e46cb7ca49f7b (patch) | |
tree | 9c90af5244e73f22d36a84b48bca605fe9902d3f /cava.c | |
parent | b4ad76f5775d908a4d3d9986688b18d58cfb8aa8 (diff) | |
parent | 1a99cbef669c7658566db753ab3f14478231048b (diff) |
Update upstream source from tag 'upstream/0.7.2'
Update to upstream version '0.7.2'
with Debian dir fad6dff5f4ba65cd0ada6984e8ebb9c08470eae4
Diffstat (limited to 'cava.c')
-rw-r--r-- | cava.c | 26 |
1 files changed, 15 insertions, 11 deletions
@@ -243,6 +243,7 @@ int main(int argc, char **argv) { double eq[256]; float g; struct timespec req = {.tv_sec = 0, .tv_nsec = 0}; + struct timespec sleep_mode_timer = {.tv_sec = 0, .tv_nsec = 0}; char configPath[PATH_MAX]; char *usage = "\n\ Usage : " PACKAGE " [options]\n\ @@ -746,6 +747,14 @@ as of 0.4.0 all options are specified in config file, see in '/home/username/.co number_of_bars = number_of_bars * 2; bool resizeTerminal = false; + fcntl(0, F_SETFL, O_NONBLOCK); + + if (p.framerate <= 1) { + req.tv_sec = 1 / (float)p.framerate; + } else { + req.tv_sec = 0; + req.tv_nsec = (1 / (float)p.framerate) * 1e9; + } while (!resizeTerminal) { @@ -754,6 +763,8 @@ as of 0.4.0 all options are specified in config file, see in '/home/username/.co if (output_mode == OUTPUT_NCURSES) ch = getch(); #endif + if (output_mode == OUTPUT_NONCURSES) + ch = fgetc(stdin); switch (ch) { case 65: // key up @@ -880,9 +891,9 @@ as of 0.4.0 all options are specified in config file, see in '/home/username/.co printw("no sound detected for 5 sec, going to sleep mode\n"); #endif // wait 0.1 sec, then check sound again. - req.tv_sec = 0; - req.tv_nsec = 100000000; - nanosleep(&req, NULL); + sleep_mode_timer.tv_sec = 0; + sleep_mode_timer.tv_nsec = 100000000; + nanosleep(&sleep_mode_timer, NULL); continue; } @@ -1015,14 +1026,6 @@ as of 0.4.0 all options are specified in config file, see in '/home/username/.co resizeTerminal = true; #endif - if (p.framerate <= 1) { - req.tv_sec = 1 / (float)p.framerate; - } else { - req.tv_sec = 0; - req.tv_nsec = (1 / (float)p.framerate) * 1000000000; - } - - nanosleep(&req, NULL); memcpy(previous_frame, bars, 256 * sizeof(int)); @@ -1033,6 +1036,7 @@ as of 0.4.0 all options are specified in config file, see in '/home/username/.co exit(EXIT_FAILURE); } + nanosleep(&req, NULL); } // resize terminal } // reloading config |