diff --git a/src/engine/platform/pcspkr.cpp b/src/engine/platform/pcspkr.cpp index eb201c1e..54048f90 100644 --- a/src/engine/platform/pcspkr.cpp +++ b/src/engine/platform/pcspkr.cpp @@ -19,10 +19,13 @@ #include "pcspkr.h" #include "../engine.h" +#include #include +#include #ifdef __linux__ #include +#include #include #include #endif @@ -112,14 +115,29 @@ void DivPlatformPCSpeaker::acquire_piezo(short* bufL, short* bufR, size_t start, } } -void DivPlatformPCSpeaker::acquire_real(short* bufL, short* bufR, size_t start, size_t len) { +void DivPlatformPCSpeaker::beepFreq(int freq) { #ifdef __linux__ + static struct input_event ie; + if (beepFD>=0) { + gettimeofday(&ie.time,NULL); + ie.type=EV_SND; + ie.code=SND_TONE; + ie.value=freq; + if (write(beepFD,&ie,sizeof(struct input_event))<0) { + perror("error while writing frequency!"); + } else { + //printf("writing freq: %d\n",freq); + } + } +#endif +} + +void DivPlatformPCSpeaker::acquire_real(short* bufL, short* bufR, size_t start, size_t len) { if (lastOn!=on || lastFreq!=freq) { lastOn=on; lastFreq=freq; - ioctl(STDOUT_FILENO,KIOCSOUND,on?freq:0); + beepFreq((on && !isMuted[0])?freq:0); } -#endif for (size_t i=start; i=0) close(beepFD); +#endif } DivPlatformPCSpeaker::~DivPlatformPCSpeaker() { diff --git a/src/engine/platform/pcspkr.h b/src/engine/platform/pcspkr.h index 6197098a..82e0f461 100644 --- a/src/engine/platform/pcspkr.h +++ b/src/engine/platform/pcspkr.h @@ -53,7 +53,7 @@ class DivPlatformPCSpeaker: public DivDispatch { Channel chan[1]; bool isMuted[1]; bool on, flip, lastOn; - int pos, speakerType; + int pos, speakerType, beepFD; float low, band; float low2, high2, band2; float low3, band3; @@ -62,6 +62,8 @@ class DivPlatformPCSpeaker: public DivDispatch { friend void putDispatchChan(void*,int,int); + void beepFreq(int freq); + void acquire_unfilt(short* bufL, short* bufR, size_t start, size_t len); void acquire_cone(short* bufL, short* bufR, size_t start, size_t len); void acquire_piezo(short* bufL, short* bufR, size_t start, size_t len);