Whats happens if a program calls bepp with invalid values for dwFreq and dwDur on a linux console? (the programmer thinks that dwFreq and dwDur are ignored by Win95). David Lee Lambert escreveu:
Changelog: Support beeping with the PC speaker when running from the Linux console
------------------------------------------------------------------------
--- dlls/kernel/console.c.v1_39 Fri May 13 15:38:16 2005 +++ dlls/kernel/console.c Fri May 13 21:02:19 2005 @@ -193,9 +193,19 @@ */ BOOL WINAPI Beep( DWORD dwFreq, DWORD dwDur ) { - static const char beep = '\a'; - /* dwFreq and dwDur are ignored by Win95 */ - if (isatty(2)) write( 2, &beep, 1 ); + if (strcmp(getenv("TERM"),"linux")==0 && isatty(2)) { + /* the Linux console supports setting frequency and duration */ + char szBeep[50]; + snprintf(szBeep,50,"\x1B[10;%d]\x1B[11;%d]\a",(int)dwFreq,(int)dwDur); + write( 2, szBeep, strlen(szBeep) ); + usleep(dwDur*1000); + } else if (isatty(2)) { + /* dwFreq and dwDur are ignored by Win95 */ + static const char beep = '\a'; + write( 2, &beep, 1 ); + } else { + /* TODO: we could play a .wav file instead... */ + } return TRUE; }
participants (1)
-
Marcelo Duarte