FvwmAudio Patch, Re: FVWM: FvwmAudio, from fvwm2-modules-2.0.43-1.rpm, core dumps

From: Christophe MARTIN <cmartin_at_ipnl.in2p3.fr>
Date: Tue, 7 Jan 1997 09:44:38 +0100

Hello
>>[...]
>> My question is this, I keep getting core dumps from FvwmAudio.
>> I have it set to use /bin/play, a program which came with
>> the commercial OSS/Linux Sound Drivers that I am using to
>> get sound. They are version 2.0.18 BETA. I have NO problems
>> using play from the command line, and the fvwm2rc that I use
>> was someone elses, and it was reported by the author to have
>> worked fine. I can cat files to /dev/dsp and /dev/audio.
>> I have tried both wav and au files. I have searched this
>> list via the Web based archive, and didn't find this addressed.
>> I use RedHat 4.0, and thus, installed fvwm2 and its addons via the
>> rpm utility. rpm --query gives me these the following version info:
>>
>> fvwm2-2.0.43-1
>> fvwm2-utils-2.0.43-1
>> fvwm2-icons-2.0.43-1
>> fvwm2-modules-2.0.43-1
>>
>> which are all the latest versions I could find. The redhat list
>> yielded no reports of such behaviour, so I am wondering if
>> it could be the commercial sound drivers I use?
>>
>> I have read the FAQ, done a deja-news search, searched this lists
>> archive, searched redhat's list, and tried different sound players
>> and different sound formats. I DID everything I knew to do, and thus
>> have subscribed to this list in hopes that I missed something.
>>
>> Thanks a lot for any input.
I don't know if it has something to do with your problems, but I was having
hard time with FvwmAudio that didn't play the sounds I want. So I
investigated the code and I found little bugs.

I've made a patch for this that fixes 2 or 3 little things :
 - FvwmAudio doesn't read messages it is not interrested in,
    thus desynchronize,
 - at startup FvwmAudio plays shutdown sound,
 - keep time stamp even if no sound is played,
 - malloc(3) and free(3) much more than needed.

I hear much more sounds now. I use an external play program, not
rplay, but it should still work with rplay.

    BTW, does anyone know how to have the little window showing
coordinates/sizes when moving/resising appear in the center of the screen
rather than the upper left corner ? I think I did it once ( or was it
with Fvwm95 ? ) but I just can't remember how.

        Thanks.
        Christophe Martin
--
char*p="[)1++++++11+(QI1)9191991)9)1)(II1)919Y91)9)1)(AK+9;991+3*(9I1*IY991)Q1\
)(1I1))A91991)Q1)(+)1)1++9;)Q1+(";main(){int _;while(*p){for(_=*p-32>>3;_;--_)
putchar(' ');if(!(_=*p++-32&7))putchar('\n');else while(_--)printf("_/");}}
---%<------%<------%<------%<------%<------%<------%<------%<------%<------%<--
--- FvwmAudio.c.orig	Wed May 17 14:55:00 1995
+++ FvwmAudio.c	Sun Dec 29 03:01:52 1996
_at_@ -90,7 +90,9 @@
 int	fd_width;
 int	fd[2];
 char	audio_play_cmd_line[BUFSIZE], audio_play_dir[BUFSIZE];
-time_t	audio_delay = 0;	/* seconds */
+time_t	audio_delay = 0,	/* seconds */
+        last_time = 0,
+        now;
 #ifdef HAVE_RPLAY
 int	rplay_fd = -1;
 #endif
_at_@ -128,10 +130,11 @@
 	"end_config_info",
 	"icon_file",
 	"default_icon",
+	"string",
 /* add builtins here */
 	"startup",
 	"shutdown",
-	"unknown",
+	"unknown"
 };
 
 /* define the sound table  */
_at_@ -146,13 +149,6 @@
 {
 	char *temp, *s;
 
-	if ((argc != 6)&&(argc != 7))
-	{
-		fprintf(stderr,"%s Version %s should only be executed by fvwm!\n",
-			MyName, VERSION);
-		exit(1);
-	}
-
 	/* Save our program  name - for error messages */
 	temp = argv[0];
 	s=strrchr(argv[0], '/');
_at_@ -163,6 +159,14 @@
 	strcpy(MyName,"*");
 	strcat(MyName, temp);
 
+	if ((argc != 6)&&(argc != 7))
+	{
+		fprintf(stderr,"%s Version %s should only be executed by fvwm!\n",
+			MyName, VERSION);
+		exit(1);
+	}
+
+
 	/* Dead pipe == Fvwm died */
 	signal (SIGPIPE, DeadPipe);  
   
_at_@ -353,10 +357,23 @@
  ***********************************************************************/
 void Loop(int *fd)
 {
-	unsigned long	header[HEADER_SIZE], *body;
-	char		*cbody;
+/* should find something better for resyncing */
+#define RESYNC( ) continue
+
+#define READ_BODY( ) do {                                   \
+	total = 0;                                              \
+	while(total < body_length*sizeof(unsigned long))        \
+	{                                                       \
+		if((count2=read(fd[1],&body[total],                 \
+			body_length*sizeof(unsigned long)-total)) >0)   \
+			total += count2;                                \
+		else if(count2 < 0)                                 \
+			DeadPipe(0);                                    \
+	}                                                       \
+} while( 0 )
+
+	unsigned long	header[HEADER_SIZE], body[ MAX_BODY_SIZE ];
 	int		body_length,count,count2=0, total;
-	time_t 		now, last_time = 0;
 	unsigned long	code;
 	
 	while (1)
_at_@ -369,53 +386,42 @@
 			 * period.
 			 */
 			now = time(0);
+			body_length = header[2]-HEADER_SIZE;
+			if( header[ 0 ] != START_FLAG )
+				RESYNC( );
 			if (now < (last_time + audio_delay))
 			{
+				/*
+				 * read the message so we are still synchronized
+				 */
+				READ_BODY( );
 				continue;
 			}
-			last_time = now;
 			
-			if(header[0] == START_FLAG)
-			{
-				body_length = header[2]-HEADER_SIZE;
-				body = (unsigned long *)
-					safemalloc(body_length * sizeof(unsigned long));
-				cbody = (char *)body;
-				total = 0;
-				while(total < body_length*sizeof(unsigned long))
-				{
-					if((count2=read(fd[1],&cbody[total],
-						body_length*sizeof(unsigned long)-total)) >0)
-						total += count2;
-					else if(count2 < 0)
-						DeadPipe(0);
-				}
+			READ_BODY( );
 
-				/*
-				 * code will equal the number of shifts in the
-				 * base-2 header[1] number.  Could use log here
-				 * but this should be fast enough.
-				 */
-				code = -1;
-				while (header[1])
-				{
-					code++;
-					header[1] >>= 1;
-				}
-				
-				/*
-				 * Play the sound.
-				 */
-				if (code >= 0 && code < MAX_MESSAGES)
-				{
-					audio_play(code);
-				}
-				else
-				{
-					audio_play(BUILTIN_UNKNOWN);
-				}
-				
-				free(body);
+			/*
+			 * code will equal the number of shifts in the
+			 * base-2 header[1] number.  Could use log here
+			 * but this should be fast enough.
+			 */
+			code = -1;
+			while (header[1])
+			{
+				code++;
+				header[1] >>= 1;
+			}
+			
+			/*
+			 * Play the sound.
+			 */
+			if (code >= 0 && code < MAX_MESSAGES)
+			{
+				audio_play(code);
+			}
+			else
+			{
+				audio_play(BUILTIN_UNKNOWN);
 			}
 		}
 		if(count <= 0)
_at_@ -457,6 +463,7 @@
 int audio_play(short sound) 
 {
 	static char buf[BUFSIZE];
+	int ret;
 
 #ifdef HAVE_RPLAY
 	if (rplay_fd != -1)
_at_@ -467,6 +474,8 @@
 			{
 				rplay_perror("rplay");
 			}
+			else
+				last_time = now;
 		}
 		return 0;
 	}
_at_@ -488,7 +497,11 @@
 			sprintf(buf,"%s %s/%s &", audio_play_cmd_line, audio_play_dir,
 				sound_table[sound]);
 		}
-		return system(buf);
+
+		if( ! ( ret = system(buf))) {
+			last_time = now;
+		}
+		return ret;
 	}  
 
 	return 1;
---%<------%<------%<------%<------%<------%<------%<------%<------%<------%<--
--
Visit the official FVWM web page at <URL:http://www.hpc.uh.edu/fvwm/>.
To unsubscribe from the list, send "unsubscribe fvwm" in the body of a
message to majordomo_at_hpc.uh.edu.
To report problems, send mail to fvwm-owner_at_hpc.uh.edu.
Received on Tue Jan 07 1997 - 02:45:10 GMT

This archive was generated by hypermail 2.3.0 : Mon Aug 29 2016 - 19:37:59 BST