Compare commits

..

3 Commits

Author SHA1 Message Date
tTh
ffbc4a13d4 you can now stop the wav player with the X key 2024-08-22 00:49:48 +02:00
tTh
b372e0428d cosmetic 2024-08-20 16:52:16 +02:00
tTh
4a3408633d typo 2024-08-16 11:49:28 +02:00
4 changed files with 54 additions and 8 deletions

View File

@ -6,9 +6,14 @@
* *
*/ */
#define _POSIX_C_SOURCE 600L /* for fileno(3) */
#include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <unistd.h> #include <unistd.h>
#include <sys/select.h>
#include "ecoute.h" #include "ecoute.h"
/*==------------------------------------------------------------------==*/ /*==------------------------------------------------------------------==*/
@ -79,6 +84,42 @@ foo = 42;
return foo; return foo;
} }
/*==------------------------------------------------------------------==*/ /*==------------------------------------------------------------------==*/
/*
* detection de la frappe d'une touche clavier -- remember kbhit() ?
*/
int is_a_key_hitted(void)
{
int fd,retv;
fd_set in_fds;
struct timeval tv;
fd = fileno(stdin);
#if DEBUG_LEVEL
fprintf(stderr, "%s: fileno -> %d\n", __func__, fd);
#endif
FD_ZERO(&in_fds); FD_SET(fd, &in_fds);
tv.tv_sec = tv.tv_usec = 0;
retv = select(1, &in_fds, NULL, NULL, &tv);
#if DEBUG_LEVEL
fprintf(stderr, "%s: select -> %d\n", __func__, retv);
#endif
if (-1 == retv) {
perror("select()");
}
else if (0 == retv) {
/* no key hit */
}
else {
/* got a keypress */
return 1;
}
return 0;
}
/*==------------------------------------------------------------------==*/
void termine_ecran(void) void termine_ecran(void)
{ {
endwin(); exit(0); endwin(); exit(0);

View File

@ -57,7 +57,7 @@ int foo, len_nom, len_ext;
fprintf(stderr, "type_du_fichier(%s)\n", nom); fprintf(stderr, "type_du_fichier(%s)\n", nom);
#endif #endif
len_nom = strlen(nom); len_nom = strlen(nom);
for (foo=0; foo<NBR_TYPES; foo++) { for (foo=0; foo<(int)NBR_TYPES; foo++) {
len_ext = strlen(types_de_fichiers[foo].extension); len_ext = strlen(types_de_fichiers[foo].extension);
if ( (len_nom > len_ext) && if ( (len_nom > len_ext) &&
!strcmp(nom+(len_nom-len_ext), types_de_fichiers[foo].extension) ) { !strcmp(nom+(len_nom-len_ext), types_de_fichiers[foo].extension) ) {
@ -80,7 +80,7 @@ int foo;
if (type == SON_UNKNOW) return "unknow"; if (type == SON_UNKNOW) return "unknow";
for (foo=0; foo<NBR_TYPES; foo++) { for (foo=0; foo<(int)NBR_TYPES; foo++) {
if (type==types_de_fichiers[foo].numtype) if (type==types_de_fichiers[foo].numtype)
return (types_de_fichiers[foo].extension)+1; return (types_de_fichiers[foo].extension)+1;
} }
@ -93,7 +93,7 @@ int foo;
if (type == SON_UNKNOW) return "unknow"; if (type == SON_UNKNOW) return "unknow";
for (foo=0; foo<NBR_TYPES; foo++) { for (foo=0; foo<(int)NBR_TYPES; foo++) {
if (type==types_de_fichiers[foo].numtype) if (type==types_de_fichiers[foo].numtype)
return (types_de_fichiers[foo].descr); return (types_de_fichiers[foo].descr);
} }
@ -175,7 +175,6 @@ int foo;
WINDOW *popup; WINDOW *popup;
char chaine[100]; char chaine[100];
struct stat st; struct stat st;
long magicbits;
/* /*
* ncurses initial stuff * ncurses initial stuff

View File

@ -20,7 +20,7 @@ ao_sample_format format;
ao_device * device; ao_device * device;
char chaine[120]; char chaine[120];
short * samples; short * samples;
int lu; int lu, key;
long total_lu; long total_lu;
#if DEBUG_LEVEL #if DEBUG_LEVEL
@ -103,7 +103,13 @@ while ( (lu=sf_read_short(sndf, samples, T_BUFFER)) > 0 )
wrefresh(popup); wrefresh(popup);
/* HERE WE HAVE TO DETECT A 'STOP LISTEN' FUNCTION. */ /* HERE WE HAVE TO DETECT A 'STOP LISTEN' FUNCTION. */
if (is_a_key_hitted()) {
key = getch();
fprintf(stderr, "%s key pressed 0x%X\n", __func__, key);
if ('X' == key) {
break;
}
}
} }
/* /*

View File

@ -8,8 +8,8 @@ nécessite donc un peu de nettoyage.
## DumpGDBM ## DumpGDBM
Pour le [debug](DumpGDBM) des fichiers `key/data` géres par GDBM. Ligne de commande Pour le [debug](DumpGDBM) des fichiers `key/data` géres par GDBM.
aver une interface _readline_. Ligne de commande avec une interface _readline_.
``` ```
tth@redlady:~/Devel/KlugyTools/DumpGDBM$ ./dumpgdbm -i exemple.gdbm tth@redlady:~/Devel/KlugyTools/DumpGDBM$ ./dumpgdbm -i exemple.gdbm