Fix building audio_standalone example on linux
Signed-off-by: Saggi Mizrahi <saggi@mizrahi.cc>
This commit is contained in:
parent
1aa775eca8
commit
aaea2eb9a6
1 changed files with 44 additions and 2 deletions
|
@ -24,10 +24,52 @@
|
||||||
********************************************************************************************/
|
********************************************************************************************/
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#if defined(_WIN32)
|
||||||
#include <conio.h> // Windows only, no stardard library
|
#include <conio.h> // Windows only, no stardard library
|
||||||
|
#endif
|
||||||
#include "audio.h"
|
#include "audio.h"
|
||||||
|
|
||||||
|
#if defined(__linux)
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <termios.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
|
||||||
|
static int kbhit(void)
|
||||||
|
{
|
||||||
|
struct termios oldt, newt;
|
||||||
|
int ch;
|
||||||
|
int oldf;
|
||||||
|
|
||||||
|
tcgetattr(STDIN_FILENO, &oldt);
|
||||||
|
newt = oldt;
|
||||||
|
newt.c_lflag &= ~(ICANON | ECHO);
|
||||||
|
tcsetattr(STDIN_FILENO, TCSANOW, &newt);
|
||||||
|
oldf = fcntl(STDIN_FILENO, F_GETFL, 0);
|
||||||
|
fcntl(STDIN_FILENO, F_SETFL, oldf | O_NONBLOCK);
|
||||||
|
|
||||||
|
ch = getchar();
|
||||||
|
|
||||||
|
tcsetattr(STDIN_FILENO, TCSANOW, &oldt);
|
||||||
|
fcntl(STDIN_FILENO, F_SETFL, oldf);
|
||||||
|
|
||||||
|
if(ch != EOF)
|
||||||
|
{
|
||||||
|
ungetc(ch, stdin);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static char getch()
|
||||||
|
{
|
||||||
|
return getchar();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
#define KEY_ESCAPE 27
|
#define KEY_ESCAPE 27
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
|
@ -78,4 +120,4 @@ int main()
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue