|
|
|
|
@ -2,6 +2,7 @@ |
|
|
|
|
#include <locale.h> |
|
|
|
|
#include <stdio.h> |
|
|
|
|
#include <stdbool.h> |
|
|
|
|
#include <termios.h> |
|
|
|
|
#include <math.h> |
|
|
|
|
#include <alsa/asoundlib.h> |
|
|
|
|
#include <sys/ioctl.h> |
|
|
|
|
@ -27,23 +28,34 @@ |
|
|
|
|
#define GCC_UNUSED /* nothing */ |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
struct sigaction old_action; |
|
|
|
|
int M = 2048; |
|
|
|
|
int shared[2048]; |
|
|
|
|
int format = -1; |
|
|
|
|
unsigned int rate = 0; |
|
|
|
|
|
|
|
|
|
void sigint_handler(int sig_no GCC_UNUSED) |
|
|
|
|
bool smode = false; |
|
|
|
|
|
|
|
|
|
struct termios oldtio, newtio; |
|
|
|
|
int rc; |
|
|
|
|
|
|
|
|
|
void cleanup() |
|
|
|
|
{ |
|
|
|
|
printf("\033[0m\n"); |
|
|
|
|
system("setfont /usr/share/consolefonts/Lat2-Fixed16.psf.gz >/dev/null 2>&1"); |
|
|
|
|
system("setterm -cursor on"); |
|
|
|
|
system("setterm -blank 10"); |
|
|
|
|
system("clear"); |
|
|
|
|
system("stty echo"); |
|
|
|
|
printf("CTRL-C pressed -- goodbye\n"); |
|
|
|
|
sigaction(SIGINT, &old_action, NULL); |
|
|
|
|
kill(0, SIGINT); |
|
|
|
|
rc = tcsetattr(0, TCSAFLUSH, &oldtio); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void sig_handler(int sig_no) |
|
|
|
|
{ |
|
|
|
|
cleanup(); |
|
|
|
|
if (sig_no == SIGINT) { |
|
|
|
|
printf("CTRL-C pressed -- goodbye\n"); |
|
|
|
|
} |
|
|
|
|
signal(sig_no, SIG_DFL); |
|
|
|
|
raise(sig_no); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//ALSA audio listner
|
|
|
|
|
@ -224,7 +236,6 @@ fifomusic(void* data) |
|
|
|
|
|
|
|
|
|
int main(int argc, char **argv) |
|
|
|
|
{ |
|
|
|
|
bool smode = false; |
|
|
|
|
pthread_t p_thread; |
|
|
|
|
int thr_id GCC_UNUSED; |
|
|
|
|
char *input = "alsa"; |
|
|
|
|
@ -290,6 +301,7 @@ Options:\n\ |
|
|
|
|
\n\
|
|
|
|
|
-v print version\n\
|
|
|
|
|
"; |
|
|
|
|
char ch; |
|
|
|
|
//**END INIT**//
|
|
|
|
|
|
|
|
|
|
setlocale(LC_ALL, ""); |
|
|
|
|
@ -384,10 +396,15 @@ Options:\n\ |
|
|
|
|
//**ctrl c handler**//
|
|
|
|
|
struct sigaction action; |
|
|
|
|
memset(&action, 0, sizeof(action)); |
|
|
|
|
action.sa_handler = &sigint_handler; |
|
|
|
|
sigaction(SIGINT, &action, &old_action); |
|
|
|
|
|
|
|
|
|
action.sa_handler = &sig_handler; |
|
|
|
|
sigaction(SIGINT, &action, NULL); |
|
|
|
|
sigaction(SIGTERM, &action, NULL); |
|
|
|
|
|
|
|
|
|
rc = tcgetattr (0, &oldtio); |
|
|
|
|
memcpy(&newtio, &oldtio, sizeof (newtio)); |
|
|
|
|
newtio.c_lflag &= ~(ICANON | ECHO); |
|
|
|
|
newtio.c_cc[VMIN] = 0; |
|
|
|
|
rc = tcsetattr(0, TCSAFLUSH, &newtio); |
|
|
|
|
|
|
|
|
|
n = 0; |
|
|
|
|
if (im == 1) { |
|
|
|
|
@ -445,11 +462,9 @@ Options:\n\ |
|
|
|
|
#endif |
|
|
|
|
bw = width / bands; |
|
|
|
|
|
|
|
|
|
if (!smode) |
|
|
|
|
{ |
|
|
|
|
g = ((float)height / 1000) * pow((60 / (float)framerate), |
|
|
|
|
2.5); //calculating gravity
|
|
|
|
|
} |
|
|
|
|
//calculating gravity
|
|
|
|
|
g = ((float)height / 1000) * pow((60 / (float)framerate), 2.5); |
|
|
|
|
|
|
|
|
|
//if no bands are selected it tries to padd the default 20 if there is extra room
|
|
|
|
|
if (autoband == 1) bands = bands + (((w.ws_col) - (bw * bands + bands - 1)) / |
|
|
|
|
(bw + 1)); |
|
|
|
|
@ -502,7 +517,6 @@ Options:\n\ |
|
|
|
|
//resetting console
|
|
|
|
|
printf("\033[0m\n"); |
|
|
|
|
system("clear"); |
|
|
|
|
system("stty -echo"); |
|
|
|
|
|
|
|
|
|
printf("\033[%dm", col); //setting color
|
|
|
|
|
|
|
|
|
|
@ -526,7 +540,15 @@ Options:\n\ |
|
|
|
|
//**start main loop**//
|
|
|
|
|
while (1) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ((ch = getchar()) != EOF) { |
|
|
|
|
switch (ch) { |
|
|
|
|
case 's': |
|
|
|
|
smode = !smode; |
|
|
|
|
break; |
|
|
|
|
case 'q': |
|
|
|
|
goto exit; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//**checkint if terminal windows has been resized**//
|
|
|
|
|
|
|
|
|
|
@ -688,5 +710,8 @@ Options:\n\ |
|
|
|
|
#endif |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
return 0; |
|
|
|
|
|
|
|
|
|
exit: |
|
|
|
|
cleanup(); |
|
|
|
|
return EXIT_SUCCESS; |
|
|
|
|
} |
|
|
|
|
|