diff src/hpplay.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 c33ae14dd6d0
children 6db80f4ab17c
line wrap: on
line diff
--- a/src/hpplay.c	Thu May 24 06:30:21 2001 +0000
+++ b/src/hpplay.c	Thu May 24 07:51:33 2001 +0000
@@ -19,6 +19,8 @@
 
 /* Synched up with: Not in FSF. */
 
+/* This file Mule-ized by Ben Wing, 5-15-01. */
+
 
 /***
    NAME
@@ -51,10 +53,8 @@
 #include <config.h>
 #include "lisp.h"
 
-#include "nativesound.h"
+#include "sound.h"
 
-#include <stdlib.h>
-#include <stdio.h>
 #ifdef HPUX10
 #include <Alib.h>
 #include <CUlib.h>
@@ -71,22 +71,20 @@
 /* Functions */
 
 /* error handling */
-void player_error_internal(
-    Audio        * audio,
-    char         * text,
-    long         errorCode
-    )
+void
+player_error_internal (Audio * audio, Char_ASCII * text, long errorCode)
 {
-    char    errorbuff[132],buf[256];
+  Extbyte errorbuff[132];
+  Bufbyte *interr;
 
-    AGetErrorText(audio, errorCode, errorbuff, 131);
-    sprintf(buf,"%s: %s\n",text,errorbuff);
-    error(buf);
+  AGetErrorText (audio, errorCode, errorbuff, 131);
+  EXTERNAL_TO_C_STRING (errorbuf, interr, Qnative);
+  
+  signal_error (Qsound_error, text, build_string (interr));
 }
 
-long myHandler(audio, err_event)
-    Audio  * audio;
-    AErrorEvent  * err_event;
+long
+myHandler( Audio * audio, AErrorEvent * err_event)
 {
   player_error_internal(audio, "Internal sound error", err_event->error_code);
   return 1;			/* Must return something, was orig. an exit */
@@ -94,177 +92,154 @@
 
 /* Playing */
 void
-play_bucket_internal(audio, pSBucket, volume)
-     Audio           *audio;
-     SBucket     *pSBucket;
-     long         volume;
+play_bucket_internal( Audio *audio, SBucket *pSBucket, long volume)
 {
-    SBPlayParams    playParams;
-    AGainEntry      gainEntry;
-    ATransID        xid;
-    long            status;
-    char            * speaker;
+  SBPlayParams playParams;
+  AGainEntry gainEntry;
+  ATransID xid;
+  long status;
+
+  playParams.priority = APriorityNormal;          /* normal priority */
 
-    playParams.priority = APriorityNormal;          /* normal priority */
-
-    /*
-     * We can't signal an error, because all h*ll would break loose if
-     * we did.
-     */
-    if (SYMBOLP (Vhp_play_speaker))
-    {
-	speaker = (char *) (string_data (XSYMBOL (Vhp_play_speaker)->name));
-
-	/*
-	 * setup the playback parameters
-	 */
+  /*
+   * We can't signal an error, because all h*ll would break loose if
+   * we did.
+   */
+  if (EQ (Vhp_play_speaker, Qexternal))
+    gainEntry.u.o.out_dst = AODTMonoJack;
+  else
+    gainEntry.u.o.out_dst = AODTMonoIntSpeaker;
 
-	/* speaker selection */
-	if ( strcmp(speaker,"external") == 0 ) {
-	    gainEntry.u.o.out_dst = AODTMonoJack;
-	} else {
-	    gainEntry.u.o.out_dst = AODTMonoIntSpeaker;
-	}
-    }
-    else
-    {
-	/*
-	 * Quietly revert to the internal speaker
-	 */
-	gainEntry.u.o.out_dst = AODTMonoIntSpeaker;
-    }
+  gainEntry.u.o.out_ch = AOCTMono;
+  gainEntry.gain = AUnityGain;
+  playParams.gain_matrix.type = AGMTOutput;       /* gain matrix */
+  playParams.gain_matrix.num_entries = 1;
+  playParams.gain_matrix.gain_entries = &gainEntry;
+  playParams.play_volume = hp_play_gain;          /* play volume */
+  playParams.pause_first = False;                 /* don't pause */
+  playParams.start_offset.type = ATTSamples;      /* start offset 0 */
+  playParams.start_offset.u.samples = 0;
+  playParams.duration.type = ATTFullLength;       /* play entire sample */
+  playParams.loop_count = 1;                      /* play sample just once */
+  playParams.previous_transaction = 0;            /* no linked transaction */
+  playParams.event_mask = 0;                      /* don't solicit any events */
 
-    gainEntry.u.o.out_ch = AOCTMono;
-    gainEntry.gain = AUnityGain;
-    playParams.gain_matrix.type = AGMTOutput;       /* gain matrix */
-    playParams.gain_matrix.num_entries = 1;
-    playParams.gain_matrix.gain_entries = &gainEntry;
-    playParams.play_volume = hp_play_gain;          /* play volume */
-    playParams.pause_first = False;                 /* don't pause */
-    playParams.start_offset.type = ATTSamples;      /* start offset 0 */
-    playParams.start_offset.u.samples = 0;
-    playParams.duration.type = ATTFullLength;       /* play entire sample */
-    playParams.loop_count = 1;                      /* play sample just once */
-    playParams.previous_transaction = 0;            /* no linked transaction */
-    playParams.event_mask = 0;                      /* don't solicit any events */
+  /*
+   * play the sound bucket
+   */
+  xid = APlaySBucket( audio, pSBucket, &playParams, NULL );
 
-    /*
-     * play the sound bucket
-     */
-    xid = APlaySBucket( audio, pSBucket, &playParams, NULL );
+  /*
+   * set close mode to prevent playback from stopping
+   *  when we close audio connection
+   */
+  ASetCloseDownMode( audio, AKeepTransactions, &status );
 
-    /*
-     * set close mode to prevent playback from stopping
-     *  when we close audio connection
-     */
-    ASetCloseDownMode( audio, AKeepTransactions, &status );
-
-    /*
-     *  That's all, folks!
-     *  Always destroy bucket and close connection.
-     */
-    ADestroySBucket( audio, pSBucket, &status );
-    ACloseAudio( audio, &status );
+  /*
+   *  That's all, folks!
+   *  Always destroy bucket and close connection.
+   */
+  ADestroySBucket( audio, pSBucket, &status );
+  ACloseAudio( audio, &status );
 }
 
 void
-play_sound_file (sound_file, volume)
-     char * sound_file;
-     int volume;
+play_sound_file (Extbyte * sound_file, int volume)
 {
-    SBucket         *pSBucket;
-    Audio           *audio;
-    long            status;
-    AErrorHandler   prevHandler;  /* pointer to previous handler */
-    char            *server;
+  sbucket *pSBucket;
+  Audio *audio;
+  long status;
+  AErrorHandler prevHandler;  /* pointer to previous handler */
+  Extbyte *server;
 
-    if (STRINGP(Vhp_play_server))
-      server = (char *) XSTRING_DATA (Vhp_play_server);
+  if (STRINGP (Vhp_play_server))
+    LISP_STRING_TO_EXTERNAL (Vhp_play_server, server, Qnative);
+  else
     server = "";
 
-    /*
-     *  open audio connection
-     */
-    audio = AOpenAudio( server, &status );
-    if( status ) {
-        player_error_internal( audio, "Open audio failed", status );
+  /*
+   *  open audio connection
+   */
+  audio = AOpenAudio( server, &status );
+  if( status )
+    {
+      player_error_internal( audio, "Open audio failed", status );
     }
 
-    /* replace default error handler */
-    prevHandler = ASetErrorHandler(myHandler);
+  /* replace default error handler */
+  prevHandler = ASetErrorHandler(myHandler);
 
-    /*
-     *  Load the audio file into a sound bucket
-     */
+  /*
+   *  Load the audio file into a sound bucket
+   */
 
-    pSBucket = ALoadAFile( audio, sound_file, AFFUnknown, 0, NULL, NULL );
+  pSBucket = ALoadAFile( audio, sound_file, AFFUnknown, 0, NULL, NULL );
 
-    /*
-     * Play the bucket
-     */
+  /*
+   * Play the bucket
+   */
 
-    play_bucket_internal(audio, pSBucket, volume);
+  play_bucket_internal(audio, pSBucket, volume);
 
-    ASetErrorHandler(prevHandler);    
+  ASetErrorHandler(prevHandler);    
 }
 
 
 int
-play_sound_data (data, length, volume)
-     unsigned char * data;
-     int length;
-     int volume;
+play_sound_data (UChar_Binary * data, int length, int volume)
 {
-    SBucket         *pSBucket;
-    Audio           *audio;
-    AErrorHandler   prevHandler;
-    SunHeader       *header;
-    long            status;
-    char            *server;
-    int             result;
+  SBucket *pSBucket;
+  Audio *audio;
+  AErrorHandler prevHandler;
+  SunHeader *header;
+  long status;
+  Extbyte *server;
+  int result;
 
-    /* #### Finish this to return an error code.
-       This function signal a lisp error. How consistent with the rest.
-       What if this function is needed in doing the beep for the error?
+  /* #### Finish this to return an error code.
+     This function signal a lisp error. How consistent with the rest.
+     What if this function is needed in doing the beep for the error?
 
-       Apparently the author of this didn't read the comment in
-       Fplay_sound.
-    */
+     Apparently the author of this didn't read the comment in
+     Fplay_sound.
+  */
        
     
-    if (STRINGP (Vhp_play_server))
-      server = (char *) XSTRING_DATA (Vhp_play_server);
+  if (STRINGP (Vhp_play_server))
+    LISP_STRING_TO_EXTERNAL (Vhp_play_server, server, Qnative);
+  else
     server = "";
 
-    /* open audio connection */
-    audio = AOpenAudio( server, &status );
-    if( status ) {
-        player_error_internal( audio, "Open audio failed", status );
+  /* open audio connection */
+  audio = AOpenAudio( server, &status );
+  if(status)
+    {
+      player_error_internal( audio, "Open audio failed", status );
     }
 
-    /* replace default error handler */
-    prevHandler = ASetErrorHandler (myHandler);
+  /* replace default error handler */
+  prevHandler = ASetErrorHandler (myHandler);
 
-    /* Create sound bucket */
-    header = (SunHeader *) data;
+  /* Create sound bucket */
+  header = (SunHeader *) data;
 
-    pSBucket = ACreateSBucket(audio, NULL, NULL, &status);
-    if (status)
-      player_error_internal( audio, "Bucket creation failed", status );
+  pSBucket = ACreateSBucket(audio, NULL, NULL, &status);
+  if (status)
+    player_error_internal( audio, "Bucket creation failed", status );
 
-    APutSBucketData(audio, pSBucket, 0, (char *) (data + header->header_size), header->data_length, &status);
+  APutSBucketData(audio, pSBucket, 0, (Char_Binary *) (data + header->header_size), header->data_length, &status);
 
-   if (status)
-      player_error_internal( audio, "Audio data copy failed", status );
+  if (status)
+    player_error_internal( audio, "Audio data copy failed", status );
 
-    /* Play sound */
-    play_bucket_internal(audio, pSBucket, volume);
+  /* Play sound */
+  play_bucket_internal(audio, pSBucket, volume);
 
-    ASetErrorHandler(prevHandler);
-    if (status)
-      player_error_internal( audio, "Audio data copy failed", status );
+  ASetErrorHandler(prevHandler);
+  if (status)
+    player_error_internal( audio, "Audio data copy failed", status );
 
-    return 1;
+  return 1;
 }
 
 void
@@ -288,7 +263,7 @@
 
   Vhp_play_speaker = intern ("internal");
 
-  DEFVAR_INT("hp-play-gain", &hp_play_gain /*
+  DEFVAR_INT ("hp-play-gain", &hp_play_gain /*
 Global gain value for playing sounds.
 Default value is AUnityGain which means keep level.
 Please refer to the HP documentation, for instance in