diff src/sgiplay.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 576fb035e263
children 13e3d7ae7155
line wrap: on
line diff
--- a/src/sgiplay.c	Thu May 24 06:30:21 2001 +0000
+++ b/src/sgiplay.c	Thu May 24 07:51:33 2001 +0000
@@ -21,17 +21,15 @@
 
 /* Synched up with: Not in FSF. */
 
+/* This file Mule-ized by Ben Wing, 5-15-01. */
+
 #include <config.h>
 #include "lisp.h"
 
-#include <string.h>
-#include <sys/file.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <audio.h>
-#include <netinet/in.h>		/* for ntohl() etc. */
+#include "sound.h"
+
+#include "sysfile.h"
+#include "sysproc.h" /* netinet/in.h for ntohl() etc. */
 
 /* Configuration options */
 
@@ -91,14 +89,6 @@
 #define DEFAULT_CHANNEL_COUNT	     1
 #define DEFAULT_FORMAT	      AFmulaw8
 
-/* Exports */
-
-/* all compilers on machines that have the SGI audio library
-   understand prototypes, right? */
-
-extern void play_sound_file (char *, int);
-extern void play_sound_data (unsigned char *, int, int);
-
 /* Data structures */
 
 /* an AudioContext describes everything we want to know about how a
@@ -182,8 +172,8 @@
 /* Forward declarations */
 
 static Lisp_Object close_sound_file (Lisp_Object);
-static AudioContext audio_initialize (unsigned char *, int, int);
-static void play_internal (unsigned char *, int, AudioContext);
+static AudioContext audio_initialize (UChar_Binary *, int, int);
+static void play_internal (UChar_Binary *, int, AudioContext);
 static void drain_audio_port (AudioContext);
 static void write_mulaw_8_chunk (void *, void *, AudioContext);
 static void write_linear_chunk (void *, void *, AudioContext);
@@ -209,11 +199,11 @@
 }
 
 void
-play_sound_file (char *sound_file, int volume)
+play_sound_file (Extbyte *sound_file, int volume)
 {
   int count = specpdl_depth ();
   int input_fd;
-  unsigned char buffer[CHUNKSIZE];
+  UChar_Binary buffer[CHUNKSIZE];
   int bytes_read;
   AudioContext ac = (AudioContext) 0;
 
@@ -264,7 +254,7 @@
 }
 
 void
-play_sound_data (unsigned char *data, int length, int volume)
+play_sound_data (UChar_Binary *data, int length, int volume)
 {
   int count = specpdl_depth ();
   AudioContext ac;
@@ -278,7 +268,7 @@
 }
 
 static AudioContext
-audio_initialize (unsigned char *data, int length, int volume)
+audio_initialize (UChar_Binary *data, int length, int volume)
 {
   Lisp_Object audio_port_state[3];
   static AudioContextRec desc;
@@ -293,7 +283,7 @@
   if (LOOKING_AT_SND_HEADER_P (data))
     {
       if (parse_snd_header (data, length, & desc)==-1)
-	report_file_error ("decoding .snd header", Qnil);
+	report_sound_error ("decoding .snd header", Qunbound);
     }
   else
 #endif
@@ -322,17 +312,17 @@
 }
 
 static void
-play_internal (unsigned char *data, int length, AudioContext ac)
+play_internal (UChar_Binary *data, int length, AudioContext ac)
 {
-  unsigned char * limit;
+  UChar_Binary * limit;
   if (ac == (AudioContext) 0)
     return;
 
-  data = (unsigned char *) ac->ac_data;
+  data = (UChar_Binary *) ac->ac_data;
   limit = data + ac->ac_size;
   while (data < limit)
     {
-      unsigned char * chunklimit = data + CHUNKSIZE;
+      UChar_Binary * chunklimit = data + CHUNKSIZE;
 
       if (chunklimit > limit)
 	chunklimit = limit;
@@ -375,8 +365,8 @@
 static void
 write_mulaw_8_chunk (void *buffer, void *chunklimit, AudioContext ac)
 {
-  unsigned char * data = (unsigned char *) buffer;
-  unsigned char * limit = (unsigned char *) chunklimit;
+  UChar_Binary * data = (UChar_Binary *) buffer;
+  UChar_Binary * limit = (UChar_Binary *) chunklimit;
   short * obuf, * bufp;
   long n_samples = limit - data;
 
@@ -398,7 +388,7 @@
   switch (ac->ac_format)
     {
     case AFlinear16: n_samples = (short *) limit - (short *) data; break;
-    case AFlinear8:  n_samples =  (char *) limit -  (char *) data; break;
+    case AFlinear8:  n_samples =  (Char_Binary *) limit -  (Char_Binary *) data; break;
     default: n_samples =  (long *) limit -  (long *) data; break;
     }
   ALwritesamps (ac->ac_port, data, (long) n_samples);
@@ -457,7 +447,7 @@
     {
       if ((open_audio_port (return_ac, desc))==-1)
 	{
-	  report_file_error ("Open audio port", Qnil);
+	  report_sound_error ("Open audio port", Qunbound);
 	  return (AudioContext) 0;
 	}
     }
@@ -514,7 +504,7 @@
   ALfreeconfig (config);
   if (return_ac->ac_port==0)
     {
-      report_file_error ("Opening audio output port", Qnil);
+      report_sound_error ("Opening audio output port", Qunbound);
       return -1;
     }
   return 0;
@@ -530,8 +520,8 @@
     case 2: ALsetchannels (config, AL_STEREO); break;
 #endif /* HAVE_STEREO */
     default:
-      report_file_error ("Unsupported channel count",
-			 Fcons (make_int (nchan), Qnil));
+      report_sound_error ("Unsupported channel count",
+			  make_int (nchan));
       return -1;
     }
   return 0;
@@ -567,8 +557,7 @@
 #endif
 #endif
     default:
-      report_file_error ("Unsupported audio format",
-			 Fcons (make_int (format), Qnil));
+      report_sound_error ("Unsupported audio format", make_int (format));
       return -1;
     }
   old_samplesize = ALgetwidth (config);
@@ -612,7 +601,7 @@
   int dataFormat;
   int samplingRate;
   int channelCount;
-  char info[4];
+  Char_Binary info[4];
 }
 SNDSoundStruct;
 #define SOUND_TO_HOST_INT(x) ntohl(x)
@@ -684,8 +673,8 @@
     }
   desc->ac_output_rate = SOUND_TO_HOST_INT (hp->samplingRate);
   desc->ac_nchan = SOUND_TO_HOST_INT (hp->channelCount);
-  desc->ac_data = (char *) header + SOUND_TO_HOST_INT (hp->dataLocation);
-  limit = (char *) header + length - (char *) desc->ac_data;
+  desc->ac_data = (Char_Binary *) header + SOUND_TO_HOST_INT (hp->dataLocation);
+  limit = (Char_Binary *) header + length - (Char_Binary *) desc->ac_data;
   desc->ac_size = SOUND_TO_HOST_INT (hp->dataSize);
   if (desc->ac_size > limit) desc->ac_size = limit;
   return 0;