diff src/libsst.c @ 563:183866b06e0b

[xemacs-hg @ 2001-05-24 07:50:48 by ben] Makefile.in.in, abbrev.c, alloc.c, buffer.c, bytecode.c, callint.c, callproc.c, casetab.c, chartab.c, cmdloop.c, cmds.c, console-msw.c, console-msw.h, console-stream.c, console-tty.c, console-x.c, console.c, data.c, database.c, debug.c, device-gtk.c, device-msw.c, device-tty.c, device-x.c, device.c, dialog-gtk.c, dialog-msw.c, dialog-x.c, dialog.c, dired-msw.c, dired.c, doc.c, doprnt.c, dragdrop.c, editfns.c, eldap.c, eldap.h, elhash.c, emacs-widget-accessors.c, emacs.c, emodules.c, esd.c, eval.c, event-Xt.c, event-gtk.c, event-msw.c, event-stream.c, events.c, extents.c, faces.c, file-coding.c, fileio.c, filelock.c, floatfns.c, fns.c, font-lock.c, frame-gtk.c, frame-x.c, frame.c, general-slots.h, glade.c, glyphs-gtk.c, glyphs-msw.c, glyphs-widget.c, glyphs-x.c, glyphs.c, glyphs.h, gpmevent.c, gui-gtk.c, gui-x.c, gui.c, gutter.c, hpplay.c, indent.c, input-method-xlib.c, insdel.c, intl.c, keymap.c, libsst.c, libsst.h, linuxplay.c, lisp.h, lread.c, lstream.c, lstream.h, macros.c, marker.c, md5.c, menubar-gtk.c, menubar-msw.c, menubar-x.c, menubar.c, minibuf.c, miscplay.c, miscplay.h, mule-ccl.c, mule-charset.c, mule-wnnfns.c, mule.c, nas.c, ntplay.c, ntproc.c, objects-gtk.c, objects-msw.c, objects-x.c, objects.c, postgresql.c, print.c, process-nt.c, process-unix.c, process.c, ralloc.c, rangetab.c, redisplay.c, scrollbar.c, search.c, select-gtk.c, select-x.c, select.c, sgiplay.c, sheap.c, sound.c, specifier.c, sunplay.c, symbols.c, symeval.h, symsinit.h, syntax.c, sysdep.c, toolbar-msw.c, toolbar.c, tooltalk.c, ui-byhand.c, ui-gtk.c, undo.c, unexaix.c, unexapollo.c, unexconvex.c, unexec.c, widget.c, win32.c, window.c: -- defsymbol -> DEFSYMBOL. -- add an error type to all errors. -- eliminate the error functions in eval.c that let you just use Qerror as the type. -- redo the error API to be more consistent, sensibly named, and easier to use. -- redo the error hierarchy somewhat. create new errors: structure-formation-error, gui-error, invalid-constant, stack-overflow, out-of-memory, process-error, network-error, sound-error, printing-unreadable-object, base64-conversion- error; coding-system-error renamed to text-conversion error; some others. -- fix Mule problems in error strings in emodules.c, tooltalk.c. -- fix error handling in mswin open-network-stream. -- Mule-ize all sound files and clean up the headers. -- nativesound.h -> sound.h and used for all sound files. -- move some shared stuff into glyphs-shared.c: first attempt at eliminating some of the massive GTK code duplication. xemacs.mak: add glyphs-shared.c. xemacs-faq.texi: document how to debug X errors subr.el: fix doc string to reflect reality
author ben
date Thu, 24 May 2001 07:51:33 +0000
parents 84b14dcb0985
children 943eaba38521
line wrap: on
line diff
--- a/src/libsst.c	Thu May 24 06:30:21 2001 +0000
+++ b/src/libsst.c	Thu May 24 07:51:33 2001 +0000
@@ -15,21 +15,18 @@
 
 /* Synched up with: Not in FSF. */
 
-#ifdef emacs
+/* This file Mule-ized by Ben Wing, 5-15-01. */
+
 #include <config.h>
 #include "lisp.h"
-#endif
 
-#include <stdlib.h>
-#include <stdio.h>
-#include <fcntl.h>
-
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
+#include "sound.h"
 
 #include "libsst.h"
 
+#include "sysfile.h"
+
+
 #define AUDBUF 1024
 
 int
@@ -38,12 +35,12 @@
     {
     int fd, i, gr, ger, gx;
     struct audio_ioctl ai;
-    char *ep;
+    Extbyte *ep;
 
     fd = open( "/dev/audio", O_RDWR );
     if ( fd < 0 )
 	{
-	perror( "sst_open: open /dev/audio" );
+	sound_perror( "sst_open: open /dev/audio" );
 	return( fd );
 	}
 
@@ -53,7 +50,7 @@
     i = AUDBUF;
     if ( ioctl( fd, AUDIOSETQSIZE, &i ) < 0 )
 	{
-	perror( "sst_open: SETQSIZE" );
+	sound_perror( "sst_open: SETQSIZE" );
 	return( fd );
 	}
 #endif /* AUDIOSETQSIZE */
@@ -67,7 +64,7 @@
 	    play_level = atoi( ep );
 	    if ( play_level < 0 || play_level > 99 )
 	    {
-		warn( "sst_open: SST_PLAY must be between 0 and 99" );
+		sound_warn( "sst_open: SST_PLAY must be between 0 and 99" );
 		return( -1 );
 	    }
 	}
@@ -80,7 +77,7 @@
 	    record_level = atoi( ep );
 	    if ( record_level < 0 || record_level > 99 )
 	    {
-		warn( "sst_open: SST_RECORD must be between 0 and 99" );
+		sound_warn( "sst_open: SST_RECORD must be between 0 and 99" );
 		return( -1 );
 	    }
 	}
@@ -110,7 +107,7 @@
     ai.control = AUDIO_MAP_MMR2;
     if ( ioctl( fd, AUDIOGETREG, &ai ) < 0 )
 	{
-	perror( "sst_open: GETREG MMR2" );
+	sound_perror( "sst_open: GETREG MMR2" );
 	return( -1 );
 	}
     if ( (ep = getenv( "SST_EARPHONES" )) != NULL )
@@ -119,7 +116,7 @@
 	ai.data[0] |= AUDIO_MMR2_BITS_LS;
     if ( ioctl( fd, AUDIOSETREG, &ai ) < 0 )
 	{
-	perror( "sst_open: SETREG MMR2" );
+	sound_perror( "sst_open: SETREG MMR2" );
 	return( fd );
 	}
 
@@ -136,13 +133,13 @@
     ai.data[0] = 0;
     if ( ioctl( fd, AUDIOSETREG, &ai ) < 0 )
 	{
-	perror( "sst_close: SETREG MMR1" );
+	sound_perror( "sst_close: SETREG MMR1" );
 	}
     ai.control = AUDIO_MAP_MMR2;
     ai.data[0] = 0;
     if ( ioctl( fd, AUDIOSETREG, &ai ) < 0 )
 	{
-	perror( "sst_close: SETREG MMR2" );
+	sound_perror( "sst_close: SETREG MMR2" );
 	}
     close( fd );
     }
@@ -150,7 +147,7 @@
 /* These are tables of values to be loaded into various gain registers.
 */
 
-static unsigned char ger_table[][2] = {
+static UChar_Binary ger_table[][2] = {
     0xaa,	0xaa,	/* -10db */
     0x79,	0xac,
     0x41,	0x99,
@@ -183,7 +180,7 @@
     };
 
 
-static unsigned char gr_gx_table[][2] = {
+static UChar_Binary gr_gx_table[][2] = {
     0x8b,	0x7c,	/* -18db */
     0x8b,	0x35,
     0x8b,	0x24,
@@ -225,9 +222,9 @@
 
     if ( ( value < -10 ) || ( value > 18 ) )
 	{
-	  char buf [255];
+	  Extbyte buf [255];
 	  sprintf (buf, "sst_set_ger: GER %d out of range", value);
-	  warn(buf);
+	  sound_warn(buf);
 	  return;
 	}
 
@@ -238,18 +235,18 @@
 
     if ( ioctl( fd, AUDIOSETREG, &ai ) < 0 )
 	{
-	perror( "sst_set_ger: SETREG GER" );
+	sound_perror( "sst_set_ger: SETREG GER" );
 	}
 
     ai.control = AUDIO_MAP_MMR1;
     if ( ioctl( fd, AUDIOGETREG, &ai ) < 0 )
 	{
-	perror( "sst_set_ger: GETREG MMR1" );
+	sound_perror( "sst_set_ger: GETREG MMR1" );
 	}
     ai.data[0] |= AUDIO_MMR1_BITS_LOAD_GER;
     if ( ioctl( fd, AUDIOSETREG, &ai ) < 0 )
 	{
-	perror( "sst_set_ger: SETREG MMR1" );
+	sound_perror( "sst_set_ger: SETREG MMR1" );
 	}
     }
 
@@ -261,9 +258,9 @@
 
     if ( ( value < -18 ) || ( value > 12 ) )
 	{
-	  char buf [255];
+	  Extbyte buf [255];
 	  sprintf (buf,  "sst_set_gr: GR %d out of range", value);
-	  warn (buf);
+	  sound_warn (buf);
 	  return;
 	}
 
@@ -273,18 +270,18 @@
 
     if ( ioctl( fd, AUDIOSETREG, &ai ) < 0 )
 	{
-	perror( "sst_set_gr: SETREG GR" );
+	sound_perror( "sst_set_gr: SETREG GR" );
 	}
 
     ai.control = AUDIO_MAP_MMR1;
     if ( ioctl( fd, AUDIOGETREG, &ai ) < 0 )
 	{
-	perror( "sst_set_gr: GETREG MMR1" );
+	sound_perror( "sst_set_gr: GETREG MMR1" );
 	}
     ai.data[0] |= AUDIO_MMR1_BITS_LOAD_GR;
     if ( ioctl( fd, AUDIOSETREG, &ai ) < 0 )
 	{
-	perror( "sst_set_gr: SETREG MMR1" );
+	sound_perror( "sst_set_gr: SETREG MMR1" );
 	}
     }
 
@@ -293,12 +290,12 @@
 int fd, value;
     {
     struct audio_ioctl ai;
-    char buf [255];
+    Extbyte buf [255];
 
     if ( ( value < -18 ) || ( value > 12 ) )
 	{
 	  sprintf (buf, "sst_set_gx: GX %d out of range", value);
-	  warn (buf);
+	  sound_warn (buf);
 	  return;
 	}
 
@@ -311,18 +308,18 @@
 
     if ( ioctl( fd, AUDIOSETREG, &ai ) < 0 )
 	{
-	perror( "sst_set_gx: SETREG GX" );
+	sound_perror( "sst_set_gx: SETREG GX" );
 	}
 
     ai.control = AUDIO_MAP_MMR1;
     if ( ioctl( fd, AUDIOGETREG, &ai ) < 0 )
 	{
-	perror( "sst_set_gx: GETREG MMR1" );
+	sound_perror( "sst_set_gx: GETREG MMR1" );
 	}
     ai.data[0] |= AUDIO_MMR1_BITS_LOAD_GX;
     if ( ioctl( fd, AUDIOSETREG, &ai ) < 0 )
 	{
-	perror( "sst_set_gx: SETREG MMR1" );
+	sound_perror( "sst_set_gx: SETREG MMR1" );
 	}
     }
 
@@ -330,10 +327,10 @@
 sst_tones( fd, dhz1, dhz2, thz, rhz, usec )
 int fd, dhz1, dhz2, thz, rhz, usec;
     {
-    char buf [255];
+    Extbyte buf [255];
     struct audio_ioctl ai;
     int dval1, dval2, tval, rval;
-    unsigned char oldmmr2, newmmr2;
+    UChar_Binary oldmmr2, newmmr2;
 
     if ( dhz1 == 0 )
 	dval1 = 0;
@@ -343,7 +340,7 @@
 	if ( ( dval1 < 1 ) || ( dval1 > 255 ) )
 	    {
 	      sprintf(buf, "sst_tones: dhz1 %d out of range", dhz1 );
-	      warn (buf);
+	      sound_warn (buf);
 	      return;
 	    }
 	}
@@ -356,7 +353,7 @@
 	if ( ( dval2 < 1 ) || ( dval2 > 255 ) )
 	    {
 	      sprintf(buf, "sst_tones: dhz2 %d out of range", dhz2 );
-	      warn (buf);
+	      sound_warn (buf);
 	      return;
 	    }
 	}
@@ -369,7 +366,7 @@
 	if ( ( tval < 1 ) || ( tval > 255 ) )
 	    {
 	      sprintf(buf, "sst_tones: thz %d out of range", thz );
-	      warn (buf);
+	      sound_warn (buf);
 	      return;
 	    }
 	}
@@ -382,7 +379,7 @@
 	if ( ( rval < 1 ) || ( rval > 255 ) )
 	    {
 	      sprintf(buf, "sst_tones: rhz %d out of range", dhz2 );
-	      warn (buf);
+	      sound_warn (buf);
 	      return;
 	    }
 	}
@@ -390,21 +387,21 @@
     if ( ( dval1 != 0 || dval2 != 0 ) && ( tval != 0 || rval != 0 ) )
 	{
 	  sprintf(buf, "sst_tones: cannot use DTMF and TONE or RINGER at the same time", dhz2 );
-	  warn (buf);
+	  sound_warn (buf);
 	  return;
 	}
 
     if ( tval != 0 && rval != 0 )
 	{
 	  sprintf(buf, "sst_tones: cannot use TONE and RINGER at the same time", dhz2 );
-	  warn (buf);
+	  sound_warn (buf);
 	return;
 	}
 
     ai.control = AUDIO_MAP_MMR2;
     if ( ioctl( fd, AUDIOGETREG, &ai ) < 0 )
 	{
-	perror( "sst_tones: GETREG MMR2" );
+	sound_perror( "sst_tones: GETREG MMR2" );
 	}
     oldmmr2 = newmmr2 = ai.data[0];
 
@@ -416,7 +413,7 @@
 	ai.data[1] = dval2;
 	if ( ioctl( fd, AUDIOSETREG, &ai ) < 0 )
 	    {
-	    perror( "sst_tones: SETREG FTGR" );
+	    sound_perror( "sst_tones: SETREG FTGR" );
 	    }
 	}
 
@@ -428,7 +425,7 @@
 	ai.data[1] = 0;
 	if ( ioctl( fd, AUDIOSETREG, &ai ) < 0 )
 	    {
-	    perror( "sst_tones: SETREG FTGR" );
+	    sound_perror( "sst_tones: SETREG FTGR" );
 	    }
 	}
 
@@ -440,7 +437,7 @@
 	ai.data[1] = 0;
 	if ( ioctl( fd, AUDIOSETREG, &ai ) < 0 )
 	    {
-	    perror( "sst_tones: SETREG FTGR" );
+	    sound_perror( "sst_tones: SETREG FTGR" );
 	    }
 	}
 
@@ -448,7 +445,7 @@
     ai.data[0] = newmmr2;
     if ( ioctl( fd, AUDIOSETREG, &ai ) < 0 )
 	{
-	perror( "sst_tones: SETREG MMR2" );
+	sound_perror( "sst_tones: SETREG MMR2" );
 	}
 
     usleep( usec );
@@ -456,16 +453,16 @@
     ai.data[0] = oldmmr2;
     if ( ioctl( fd, AUDIOSETREG, &ai ) < 0 )
 	{
-	perror( "sst_tones: SETREG MMR2" );
+	sound_perror( "sst_tones: SETREG MMR2" );
 	}
     }
 
 void
 sst_dtmf( fd, dial, usecper, usecpause )
 int fd, usecper, usecpause;
-char *dial;
+Extbyte *dial;
     {
-    char *cp;
+    Extbyte *cp;
 
     for ( cp = dial; *cp != '\0'; cp++ )
 	{
@@ -495,9 +492,9 @@
 
 	    default:
 	      {
-		char buf [255];
+		Extbyte buf [255];
 		sprintf( buf, "sst_dtmf: unknown dialing code '%c'", *cp );
-		warn (buf);
+		sound_warn (buf);
 	      }
 	    }
 	usleep( usecpause );