I received the following FvwmAudio patches from Ricky Ralston. I
don't have the ability to test them and was hoping someone on the list
could give it a whirl.
------- Start of forwarded message -------
From: Ricky Ralston <rlr_at_wscoe5.atl.hp.com>
Message-Id: <199707071838.OAA10940_at_wscoe5.atl.hp.com>
Subject: FvwmAudio with HP-UX Audio
To: boyns_at_sdsu.edu (Mark Boyns)
Date: Mon, 07 Jul 1997 14:38:58 EDT
Cc: mscott_at_mcd.mot.com, rlr_at_atl.hp.com
Hi Mark and Mark,
Here's the modifications that I promised. These mods should allow someone
to play "au" files via the HP Audio Server. I had a nice setup that allowed
more formats like "wav", but I found a memory leak in the Alib library that
could/would cause some problems. :(
I also took one liberty with the base code. I added a couple of lines to
the config() routine to setup the message mask. I thought it might be
nice and a little faster to remove unconfigured messages.
Let me know what you think,
Ricky
# This is a shell archive. Remove anything before this line,
# then unpack it by saving it in a file and typing "sh file".
#
# Wrapped by Development <wscoe_at_h0000rlr> on Mon Jul 7 14:40:34 1997
#
# This archive contains:
# Fvwm.tmpl.diff FvwmAudio.diff
#
LANG=""; export LANG
PATH=/bin:/usr/bin:$PATH; export PATH
echo x - Fvwm.tmpl.diff
cat >Fvwm.tmpl.diff <<'_at_EOF'
*** /tmp/Fvwm.tmpl Mon Jul 7 14:35:48 1997
--- Fvwm.tmpl Mon Jul 7 14:38:30 1997
***************
*** 80,86 ****
--- 80,101 ----
#define AudioLibs -L/usr/local/lib
#define AudioIncs -I/usr/local/include
+ /***************************************************************************
+ * #define HasHPAudio
+ *
+ * To add builtin support for the HP-UX Audio library. Also make sure that the
+ * include and lib settings are correct for your rplay installation.
+ * This currently only effects the FvwmAudio module.
+ *
+ * NOTE: Use the following for 10.X versions of HP-UX
+ * #define HPAudioLibs -L/opt/audio/lib
+ * #define HPAudioIncs -I/opt/audio/include
+ ***************************************************************************/
+ #define HasHPAudio NO /* YES */
+ #define HPAudioLibs
+ #define HPAudioIncs -I/usr/include/audio
+
/**************************************************************************
* InstallSample
*
***************
*** 312,317 ****
--- 327,335 ----
#ifndef HasRPlay
#define HasRPlay NO
#endif
+ #ifndef HasHPAudio
+ #define HasHPAudio NO
+ #endif
#ifndef InstallLibs
#define InstallLibs NO
#endif
***************
*** 346,351 ****
--- 364,382 ----
AUDIO_INCLUDES = AudioIncs
AUDIO_LIBRARIES = AudioLibs -lrplay
#endif
+
+ #if HasHPAudio
+ #if HasRPlay
+ AUDIO_DEFINES = -DHAVE_RPLAY -DHAVE_HPAUDIO
+ AUDIO_INCLUDES = AudioIncs HPAudioIncs
+ AUDIO_LIBRARIES = AudioLibs -lrplay HPAudioLibs -lAlib
+ #else
+ #endif
+ AUDIO_DEFINES = -DHAVE_HPAUDIO
+ AUDIO_INCLUDES = HPAudioIncs
+ AUDIO_LIBRARIES = HPAudioLibs -lAlib
+ #endif
+
#ifdef FvwmCompiler
CC = FvwmCompiler
_at_EOF
chmod 644 Fvwm.tmpl.diff
echo x - FvwmAudio.diff
cat >FvwmAudio.diff <<'_at_EOF'
*** FvwmAudio.c Fri Jan 17 11:10:49 1997
--- /tmp/FvwmAudio.c Mon Jul 7 14:31:42 1997
***************
*** 96,101 ****
--- 96,111 ----
#undef M_ERROR /* Solaris fix */
#endif
+ /* HP-UX Aserver includes */
+ #if defined (hpux) && defined (HAVE_HPAUDIO)
+ #include <sys/socket.h>
+ #include <netinet/in.h>
+ #include "Alib.h"
+
+ int HPAudio(short sound);
+ int HPAudioServer = 0;
+ #endif
+
#include "../../configure.h"
#include "../../fvwm/module.h"
#include "../../version.h"
***************
*** 231,236 ****
--- 241,247 ----
char *sound;
char *p;
int i, found;
+ long mask = 0L;
#ifdef HAVE_RPLAY
int volume = RPLAY_DEFAULT_VOLUME;
int priority = RPLAY_DEFAULT_PRIORITY;
***************
*** 368,373 ****
--- 379,385 ----
RPLAY_VOLUME, volume,
NULL);
#endif
+ if (i < MAX_MESSAGES) mask |= (1<<i);
sound_table[i]=sound;
found++;
}
***************
*** 394,399 ****
--- 406,419 ----
}
}
#endif
+
+ #if defined (hpux) && defined (HAVE_HPAUDIO)
+ if (mystrcasecmp(audio_play_cmd_line, "builtin-hpux") == 0)
+ HPAudioServer = 1;
+ #endif
+
+ if (mask) SetMessageMask(fd, mask);
+
}
/***********************************************************************
***************
*** 481,486 ****
--- 501,509 ----
void done(int n)
{
audio_play(BUILTIN_SHUTDOWN);
+ #if defined (hpux) && defined (HAVE_HPAUDIO)
+ if (HPAudioServer) HPAudio(-1);
+ #endif
exit(n);
}
***************
*** 509,514 ****
--- 532,546 ----
return 0;
}
#endif
+
+ #if defined (hpux) && defined (HAVE_HPAUDIO)
+ if (HPAudioServer)
+ {
+ if ((HPAudio(sound))) last_time = now;
+ return(0);
+ }
+ #endif
+
if (sound_table[sound])
{
memset(buf,0,BUFSIZE);
***************
*** 528,532 ****
--- 560,673 ----
return ret;
}
return 1;
+ }
+
+ int HPAudio( short sound )
+ {
+ static Audio *audio = NULL;
+ static AGainMatrix *spmatrix;
+ AudioAttrMask AttribsMask;
+ AudioAttributes Attribs;
+ ATransID xid;
+ AByteOrder byte_order;
+ SStream audioStream;
+ SSPlayParams playParams;
+ char *inBuf, *buf;
+ int len, len_written;
+ int fd;
+ int streamSocket;
+ long seekOffset, data_length;
+ FILE *pfile;
+ char afile[1024];
+
+ if ( sound == -1)
+ {
+ if (audio)
+ {
+ ASetCloseDownMode( audio, AKeepTransactions, NULL );
+ ACloseAudio( audio, NULL );
+ }
+ return(0);
+ }
+
+
+ if (sound_table[sound])
+ {
+ if (audio_play_dir[0] == '\0' || sound_table[sound][0] == '/')
+ strcpy(afile, sound_table[sound]);
+ else
+ {
+ sprintf(afile,"%s/%s", audio_play_dir, sound_table[sound]);
+ }
+ }
+ else return(0);
+
+
+ if (!audio)
+ {
+ audio = AOpenAudio( NULL, NULL );
+ spmatrix = ASimplePlayer(audio);
+ }
+
+ if((fd = open( afile, O_RDONLY )) < 0)
+ {
+ perror( "file open failed" );
+ return(0);
+ }
+ pfile = fdopen( fd, "r");
+
+ AChooseSourceAttributes( audio, NULL, pfile, AFFUnknown,
+ 0L, &Attribs, &seekOffset, &data_length,
+ &byte_order, NULL);
+
+ playParams.gain_matrix = *spmatrix;
+ playParams.play_volume = AUnityGain;
+ playParams.priority = APriorityNormal;
+ playParams.event_mask = 0;
+
+ AttribsMask = ~0;
+ xid = APlaySStream( audio, AttribsMask, &Attribs, &playParams,
+ &audioStream, NULL );
+
+ if ((streamSocket = socket( AF_INET, SOCK_STREAM, 0 )) < 0)
+ {
+ /* Socket create failed */
+ return(0);
+ }
+
+ if ((connect( streamSocket,
+ (struct sockaddr *)&audioStream.tcp_sockaddr,
+ sizeof(struct sockaddr_in) )) < 0)
+ {
+ /* Connect failed */
+ return(0);
+ }
+
+
+ lseek( fd, seekOffset, SEEK_SET );
+
+ inBuf = malloc(audioStream.max_block_size );
+ while(( len = read( fd, inBuf, audioStream.max_block_size )) > 0 )
+ {
+ buf = inBuf;
+
+ while( len > 0 )
+ {
+ if (( len_written = write( streamSocket, buf, len )) < 0 )
+ {
+ /* Write Failed */
+ return(1);
+ }
+ buf += len_written;
+ len -= len_written;
+
+ }
+ }
+
+ free( inBuf );
+ close( fd );
+ close( streamSocket );
+
+ return(1);
}
_at_EOF
chmod 644 FvwmAudio.diff
exit 0
------- End of forwarded message -------
--
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 Jul 22 1997 - 16:36:24 BST