//Stuff for a host build of TME /* * ---------------------------------------------------------------------------- * "THE BEER-WARE LICENSE" (Revision 42): * Jeroen Domburg wrote this file. As long as you retain * this notice you can do whatever you want with this stuff. If we meet some day, * and you think this stuff is worth it, you can buy me a beer in return. * ---------------------------------------------------------------------------- */ #include #include #include #include static uint8_t buf[1024]; static int wp=256, rp=0; static int soundEna=0; static int bufLen() { return (wp-rp)&1023; } int sndDone() { if (!soundEna) return 0; return (bufLen()<512); } int sndPush(uint8_t *data, int volume) { if (!soundEna) return 0; while(!sndDone()) usleep(1000); for (int i=0; i<370; i++) { int s=*data; s=(s-128)>>(7-volume); buf[wp++]=s+128; if (wp==1024) wp=0; data+=2; } return 1; } static void sndCb(void* userdata, Uint8* stream, int len) { for (int i=0; i