diff src/nas.c @ 432:3a7e78e1142d r21-2-24

Import from CVS: tag r21-2-24
author cvs
date Mon, 13 Aug 2007 11:29:58 +0200
parents 3ecd8885ac67
children 8de8e3f6228a
line wrap: on
line diff
--- a/src/nas.c	Mon Aug 13 11:29:10 2007 +0200
+++ b/src/nas.c	Mon Aug 13 11:29:58 2007 +0200
@@ -146,10 +146,18 @@
 #else
 	   char *server
 #endif
+	   );
+char *
+init_play (
+#ifdef XTOOLKIT
+	   Display *display
+#else
+	   char *server
+#endif
 	   )
 {
   char *err_message;
-  SIGTYPE (*old_sigpipe) ();
+  SIGTYPE (*old_sigpipe) (int);
 
 #ifdef XTOOLKIT
   char * server = DisplayString (display);
@@ -223,7 +231,7 @@
   return NULL;
 }
 
-void
+static void
 close_down_play (void)
 
 {
@@ -238,7 +246,7 @@
  \********************************************************************/
 
 static void
-doneCB (AuServer       *aud,
+doneCB (AuServer       *auserver,
 	AuEventHandlerRec *handler,
 	AuEvent        *ev,
 	AuPointer       data)
@@ -274,23 +282,23 @@
 
   if (list == NULL)
     {
-      unsigned char *my_buf;
+      AuPointer my_buf;
 
       if (buf==NULL)
 	{
-	  if ((my_buf=malloc (SoundNumBytes (s)))==NULL)
+	  if ((my_buf= (AuPointer) malloc (SoundNumBytes (s)))==NULL)
 	    {
 	      return;
 	    }
 
-	  if (SoundReadFile (my_buf, SoundNumBytes (s), s) != SoundNumBytes (s))
+	  if (SoundReadFile ((char *) my_buf, SoundNumBytes (s), s) != SoundNumBytes (s))
 	    {
 	      free (my_buf);
 	      return;
 	    }
 	}
       else
-	my_buf=buf;
+	my_buf = (AuPointer) buf;
 
       id = AuSoundCreateBucketFromData (aud, 
 					s,
@@ -322,6 +330,7 @@
 #endif /* CACHE_SOUNDS */
 
 
+void wait_for_sounds (void);
 void 
 wait_for_sounds (void)
 
@@ -335,11 +344,12 @@
     }
 }
 
+int play_sound_file (char *sound_file, int volume);
 int
 play_sound_file (char *sound_file,
 		 int volume)
 {
-  SIGTYPE (*old_sigpipe) ();
+  SIGTYPE (*old_sigpipe) (int);
 
 #ifdef ROBUST_PLAY
   old_sigpipe=signal (SIGPIPE, sigpipe_handle);
@@ -427,6 +437,7 @@
   return 1;
 }
 
+int play_sound_data (unsigned char *data, int length, int volume);
 int
 play_sound_data (unsigned char *data,
 		 int length, 
@@ -434,7 +445,7 @@
 {
   Sound s;
   int offset;
-  SIGTYPE (*old_sigpipe) ();
+  SIGTYPE (*old_sigpipe) (int);
 
 #if !defined (XTEVENTS)
   AuEvent         ev;
@@ -613,11 +624,11 @@
 /* Create a name from the sound. */
 
 static char *
-NameFromData (CONST unsigned char *buf,
+NameFromData (CONST char *buf,
 	      int len)
 
 {
-  unsigned char name[9];
+  char name[9];
   int i;
   char *s;
 
@@ -642,11 +653,11 @@
 
   if (i==8)
     {
-      strcpy (s=malloc (10), name);
+      strcpy (s = (char *) malloc (10), name);
     }
   else 
     {
-      strcpy (s=malloc (15), "short sound");
+      strcpy (s = (char *) malloc (15), "short sound");
     }
 
   return s;
@@ -729,15 +740,15 @@
 /* These functions here are for faking file I/O from buffer. */
 
 /* The "file" position */
-static int file_posn;
+static size_t file_posn;
 /* The length of the "file" */
-static int file_len;
+static size_t file_len;
 /* The actual "file" data. */
-CONST static char* file_data;
+static CONST void* file_data;
 
 /* Like fopen, but for a buffer in memory */
 static void
-dopen(CONST char* data, int length)
+dopen (CONST void* data, size_t length)
 {
    file_data = data;
    file_len = length;
@@ -746,15 +757,13 @@
 
 /* Like fread, but for a buffer in memory */
 static int
-dread(char* buf, int size, int nitems)
+dread (void* buf, size_t size, size_t nitems)
 {
-  int nread;
-
-  nread = size * nitems;
+  size_t nread = size * nitems;
   
   if (file_posn + nread <= file_len)
     {
-      memcpy(buf, file_data + file_posn, size * nitems);
+      memcpy(buf, (char *) file_data + file_posn, size * nitems);
       file_posn += nread;
       return nitems;
     }
@@ -766,19 +775,17 @@
 
 /* Like fgetc, but for a buffer in memory */
 static int
-dgetc()
+dgetc (void)
 {
-  int ch;
-  
   if (file_posn < file_len)
-    return file_data[file_posn++];
+    return ((char *)file_data)[file_posn++];
   else
     return -1;
 }
 
 /* Like fseek, but for a buffer in memory */
 static int
-dseek(long offset, int from)
+dseek (long offset, int from)
 {
   if (from == 0)
     file_posn = offset;
@@ -791,7 +798,7 @@
 }
 
 /* Like ftell, but for a buffer in memory */
-static int
+static long
 dtell()
 {
   return file_posn;
@@ -981,20 +988,20 @@
   if (!(s = (Sound) malloc (sizeof (SoundRec))))
     return NULL;
 
-  if ((s->formatInfo = SndOpenDataForReading (data, length)) != NULL)
+  if ((s->formatInfo = SndOpenDataForReading ((char *) data, length)) != NULL)
     {
-      if (!(SoundFileInfo[SoundFileFormatSnd].toSound) (s))
+      if (!((int(*)(Sound))(SoundFileInfo[SoundFileFormatSnd].toSound)) (s))
 	{
-	  SndCloseFile (s->formatInfo);
+	  SndCloseFile ((SndInfo *) (s->formatInfo));
 	  free (s);
 	  return NULL;
 	}
     }
-  else if ((s->formatInfo = WaveOpenDataForReading (data, length)) != NULL)
+  else if ((s->formatInfo = WaveOpenDataForReading ((char *) data, length)) != NULL)
     {
-      if (!(SoundFileInfo[SoundFileFormatWave].toSound) (s))
+      if (!((int(*)(Sound))(SoundFileInfo[SoundFileFormatWave].toSound)) (s))
 	{
-	  WaveCloseFile (s->formatInfo);
+	  WaveCloseFile ((WaveInfo *) (s->formatInfo));
 	  free (s);
 	  return NULL;
 	}
@@ -1002,4 +1009,3 @@
 
   return s;
 }
-