Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 22 Nov 1998 15:05:07 -0500 (EST)
From:      Mikhail Teterin <mi@aldan.ziplink.net>
To:        FreeBSD-gnats-submit@FreeBSD.ORG
Subject:   ports/8795: xgalaga's sound driver
Message-ID:  <199811222005.PAA17112@rtfm.ziplink.net>

next in thread | raw e-mail | index | archive | help

>Number:         8795
>Category:       ports
>Synopsis:       xgal.sndsrv.freebsd.c is out of sync with sound.h
>Confidential:   no
>Severity:       critical
>Priority:       medium
>Responsible:    freebsd-ports
>State:          open
>Quarter:
>Keywords:
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sun Nov 22 12:10:01 PST 1998
>Last-Modified:
>Originator:     Mikhail Teterin
>Organization:
Virtual Estates, Inc.
>Release:        FreeBSD 3.0-CURRENT i386
>Environment:
	

>Description:

	Currently, the xgal.sndsrv.freebsd.c, which lists 6 sound files
	is out of sync with the game's sound.h, which expects 8 different
	sounds. My version of the port's patch-ab adds the two more files
	(in the correct order) and puts a simple bounds checking in place,
	so that the next time this things get out of date, the
	xgal.sndsrv.freebsd will spit a reasonable complaint out, isntead
	of crashing and/or complaining about the absence of "(null)" sound.

>How-To-Repeat:

	Play xgalaga with sound, manage to get through the first level.
	When xgalaga switches you to the second level, the sound server
	will either die, killing the whole game, or spit a misleading
	error message.

>Fix:
	Put the following instead of the patches/patch-ab and remove the
	mentioning of core dumps in pkg/DESCR	
--- xgal.sndsrv.freebsd.c.orig	Sun Apr 12 02:03:21 1998
+++ xgal.sndsrv.freebsd.c	Sun Nov 22 15:01:01 1998
@@ -20,5 +20,5 @@
 
 
-char *FILENAME[] = {
+static const char *FILENAME[] = {
                      "/explode.raw",
                      "/firetorp.raw",
@@ -27,4 +27,8 @@
                      "/explode_big.raw",
 		     "/ddloo.raw",
+/* Two more files are now expected by the xgalaga!
+\* The order is given in the sound.h   -mi */
+                    "/warp.raw",
+                    "/smart.raw"
                    };
 
@@ -37,15 +41,13 @@
 
 /* Terminate: Signal Handler */
-void quit ()
+static void quit ()
 {
   exit (0);
 }
 
-
-
-void init (int argc, char **argv)
+static void init (int argc, char **argv)
 {
   int i;
-  char s[1024];
+  char s[FILENAME_MAX];
 
   if (argc != 3)
@@ -62,5 +64,5 @@
     strcat (s, FILENAME[i]);
     FILENAME[i] = malloc ((int)strlen (s));
-    strcpy (FILENAME[i],s);
+    strcpy ((char *)FILENAME[i],s);
     sound_buffer[i]=NULL;
     sound_size[i]=0;
@@ -78,10 +80,10 @@
               Error checking                
 */
-int setup_dsp (char *dspdev,int *is_pcsp)
+static int setup_dsp (char *dspdev,int *is_pcsp)
 {
   int dsp, frag, value;
   int mixer;
 
-  dsp = open(dspdev, O_RDWR);
+  dsp = open(dspdev, O_WRONLY);
   if (dsp < 1)
   {
@@ -134,5 +136,5 @@
    just trap this.
 */
-int do_nothing(void)
+static int do_nothing(void)
 {
     fprintf(stderr,"xgal.sndsrv: doing nothing, something is broken\n");
@@ -140,5 +142,5 @@
 }
 
-int read_sound(int k)
+static int read_sound(int k)
 {
   int i,fd,size;
@@ -174,5 +176,5 @@
 
 
-void do_everything (int dsp, int is_pcsp)
+static void do_everything (int dsp, int is_pcsp)
 {
   char k;
@@ -201,6 +203,12 @@
             terminate = 0;
         } else {
-            if(sound_size[k]==0) read_sound(k);
-            if(sound_size[k]>0 && playnum<16)  {
+ 	     if(k>=NUM_SOUNDS) {
+ 		fprintf(stderr,
+ 		"Not that many sounds known (%d >= %d)\n",
+ 		(int)k, NUM_SOUNDS);
+ 		continue;
+ 	     };
+ 	     if(sound_size[(int)k]==0) read_sound((int)k);
+ 	     if(sound_size[(int)k]>0 && playnum<16)  {
 	        position[playnum]=0;
                 playing[playnum++]=k;
@@ -252,12 +260,9 @@
 }
 
-
-
-void main (argc, argv)
+int main (argc, argv)
 int argc;
 char **argv;
 {
-  int dsp, is_pcsp, ppid;
-  char filename[512];
+  int dsp, is_pcsp;
 
   fcntl(STDIN_FILENO,F_SETFL,O_NONBLOCK);
@@ -268,3 +273,4 @@
 
   do_everything (dsp, is_pcsp);
+  return 0;
 }
>Audit-Trail:
>Unformatted:

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-ports" in the body of the message



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199811222005.PAA17112>