Browse Source

Merged revisions 7488-7489 via svnmerge from
http://svn.freepascal.org/svn/fpc/trunk

........
r7488 | jonas | 2007-05-27 13:11:13 +0200 (Sun, 27 May 2007) | 5 lines

* disabled sound/nosound for non-Linux, as the used ioctl is
Linux-specific (and at least under Mac OS X, there seems to be
no way to play sound without going via the Carbon/Quicktime/...
frameworks)

........
r7489 | marco | 2007-05-27 14:00:55 +0200 (Sun, 27 May 2007) | 2 lines

* now also fixes div hz with hz=0 for Linux, and reenables it for FreeBSD. Still needs phys console check though

........

git-svn-id: branches/fixes_2_2@7536 -

peter 18 years ago
parent
commit
456b869c8a
1 changed files with 16 additions and 7 deletions
  1. 16 7
      rtl/unix/crt.pp

+ 16 - 7
rtl/unix/crt.pp

@@ -1390,26 +1390,35 @@ Begin
   ScrollScrnRegionDown(WindMinX, CurrY, WindMaxX, WindMaxY, 1);
 End;
 
+{$ifdef linux}
+  {$define havekiocsound}
+   const  KIOCSOUND = $4B2F;    // start sound generation (0 for off)
+{$else}
+ {$ifdef FreeBSD}
+   const  KIOCSOUND =$20004b3f;
+   {$define havekiocsound}
+ {$endif}
+{$endif}
 
-const
-  KIOCSOUND = $4B2F;    // start sound generation (0 for off)
+// ioctl might fail e.g. in putty. A redirect check is not enough, 
+// needs check for physical console too.
 
 Procedure Sound(Hz: Word);
 begin
-  if not OutputRedir then
+{$ifdef havekiocsound}
+  if (not OutputRedir) and (hz>0) then 
     fpIoctl(TextRec(Output).Handle, KIOCSOUND, Pointer(1193180 div Hz));
+{$endif}
 end;
 
-
-
 Procedure NoSound;
 begin
+{$ifdef havekiocsound}
   if not OutputRedir then
     fpIoctl(TextRec(Output).Handle, KIOCSOUND, nil);
+{$endif}
 end;
 
-
-
 Procedure TextMode (Mode: word);
 {
   Only Clears Screen under linux}