Sfoglia il codice sorgente

Fix building audio_standalone example on linux

Signed-off-by: Saggi Mizrahi <saggi@mizrahi.cc>
pull/210/head
Saggi Mizrahi 8 anni fa
parent
commit
aaea2eb9a6
1 ha cambiato i file con 44 aggiunte e 2 eliminazioni
  1. +44
    -2
      examples/audio_standalone.c

+ 44
- 2
examples/audio_standalone.c Vedi File

@ -24,10 +24,52 @@
********************************************************************************************/
#include <stdio.h>
#if defined(_WIN32)
#include <conio.h> // Windows only, no stardard library
#endif
#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
int main()
@ -78,4 +120,4 @@ int main()
//--------------------------------------------------------------------------------------
return 0;
}
}

Caricamento…
Annulla
Salva