Martin Costabel <costabel(a)wanadoo.fr> writes:
> Screen message:
> Fatal error: assertion failed, file
> /usr/src/redhat/BUILD/xemacs-21.2.29/src/signal.c, line 340,
> async_timer_suppress_count > 0
This is XEmacs way of telling you that..
> #6 0x18f9dbc in alarm ()
> #7 0x107de94 in esd_open_sound () from /usr/lib/libesd.so.0
...libesd calls alarm() which it doesn't like. It use this message
because it sounds more adult dan "Libesd calls alarm(). Bad library,
bad..."
The normal fix would be to wrap the calls to libesd.so functions in
wrappers. Here is something (untested) I prepared earlier
Index: hpplay.c
===================================================================
RCS file: /usr/CVSroot/XEmacs/xemacs/src/hpplay.c,v
retrieving revision 1.4
diff -u -r1.4 hpplay.c
--- hpplay.c 1998/04/07 05:39:42 1.4
+++ hpplay.c 2000/02/21 20:01:39
@@ -51,6 +51,8 @@
#include <config.h>
#include "lisp.h"
+#include "nativesound.h"
+
#include <stdlib.h>
#include <stdio.h>
#ifdef HPUX10
@@ -61,6 +63,7 @@
#include <audio/CUlib.h>
#endif /* !HPUX 10 */
+
Lisp_Object Vhp_play_server;
Lisp_Object Vhp_play_speaker;
int hp_play_gain;
@@ -202,11 +205,11 @@
play_bucket_internal(audio, pSBucket, volume);
- ASetErrorHandler(prevHandler);
+ ASetErrorHandler(prevHandler);
}
-void
+int
play_sound_data (data, length, volume)
unsigned char * data;
int length;
@@ -218,7 +221,17 @@
SunHeader *header;
long status;
char *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?
+
+ 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);
server = "";
@@ -250,6 +263,8 @@
ASetErrorHandler(prevHandler);
if (status)
player_error_internal( audio, "Audio data copy failed", status );
+
+ return 1;
}
void
Index: linuxplay.c
===================================================================
RCS file: /usr/CVSroot/XEmacs/xemacs/src/linuxplay.c,v
retrieving revision 1.11.2.5
diff -u -r1.11.2.5 linuxplay.c
--- linuxplay.c 2000/02/13 02:01:04 1.11.2.5
+++ linuxplay.c 2000/02/21 20:01:39
@@ -58,6 +58,7 @@
#endif
#include "miscplay.h"
+#include "nativeplay.h"
#include <errno.h>
#include <fcntl.h>
@@ -277,8 +278,11 @@
}
/* XEmacs requires code both for playback of pre-loaded data and for playback
- from a soundfile; we use one function for both cases */
-static void linux_play_data_or_file(int fd,unsigned char *data,
+ from a soundfile; we use one function for both cases.
+
+ Returns 1 on succes. 0 otherwise.
+*/
+static int linux_play_data_or_file(int fd,unsigned char *data,
int length,int volume)
{
size_t (*parsesndfile)(void **dayta,size_t *sz,void **outbuf);
@@ -292,11 +296,11 @@
/* We need to read at least the header information before we can start
doing anything */
if (!data || length < HEADERSZ) {
- if (fd < 0) return;
+ if (fd < 0) return 0;
else {
length = read(fd,sndbuf,SNDBUFSZ);
if (length < HEADERSZ)
- return;
+ return 0;
data = sndbuf;
length = SNDBUFSZ; }
}
@@ -305,14 +309,16 @@
if (ffmt != fmtRaw && ffmt != fmtSunAudio && ffmt != fmtWave) {
warn("Unsupported file format (neither RAW, nor Sun/DECAudio, nor WAVE)");
- return; }
+ return 0; }
/* The VoxWare-SDK discourages opening /dev/audio; opening /dev/dsp and
properly initializing it via ioctl() is preferred */
if ((audio_fd=open(audio_dev, O_WRONLY | O_NONBLOCK, 0)) < 0) {
- perror(audio_dev);
+ /* JV. Much too verbose. In addition this can crash. See NOTE: in
+ Fplay_sound
+ perror(audio_dev); */
if (mix_fd > 0 && mix_fd != audio_fd) { close(mix_fd); mix_fd = -1; }
- return; }
+ return 0; }
/* The VoxWare-SDK discourages direct manipulation of the mixer device as
this could lead to problems, when multiple sound cards are installed */
@@ -378,12 +384,11 @@
close(audio_fd);
audio_fd = -1;
- return;
+ return 1;
}
/* Call "linux_play_data_or_file" with the appropriate parameters for
playing a soundfile */
-void play_sound_file (char *sound_file, int volume);
void play_sound_file (char *sound_file, int volume)
{
int fd;
@@ -398,9 +403,7 @@
/* Call "linux_play_data_or_file" with the appropriate parameters for
playing pre-loaded data */
-void play_sound_data (unsigned char *data, int length, int volume);
-void play_sound_data (unsigned char *data, int length, int volume)
+int play_sound_data (unsigned char *data, int length, int volume)
{
- linux_play_data_or_file(-1,data,length,volume);
- return;
+ return linux_play_data_or_file(-1,data,length,volume);
}
Index: ntplay.c
===================================================================
RCS file: /usr/CVSroot/XEmacs/xemacs/src/ntplay.c,v
retrieving revision 1.4.2.3
diff -u -r1.4.2.3 ntplay.c
--- ntplay.c 2000/02/16 02:06:41 1.4.2.3
+++ ntplay.c 2000/02/21 20:01:39
@@ -23,6 +23,7 @@
#include <stdio.h>
#include "sysfile.h"
#include "lisp.h"
+#include "nativesound.h"
#if (defined (__CYGWIN32__) || defined(__MINGW32__)) && \
CYGWIN_VERSION_DLL_MAJOR < 21
@@ -30,7 +31,7 @@
#else
#include <mmsystem.h>
#endif
-static void play_sound_data_1 (unsigned char *data, int length,
+static int play_sound_data_1 (unsigned char *data, int length,
int volume, int convert);
void play_sound_file (char *sound_file, int volume)
@@ -76,7 +77,7 @@
/* mswindows can't cope with playing a sound from alloca space so we
have to convert if necessary */
-static void play_sound_data_1 (unsigned char *data, int length, int volume,
+static int play_sound_data_1 (unsigned char *data, int length, int volume,
int convert_to_malloc)
{
DWORD flags = SND_ASYNC | SND_MEMORY | SND_NODEFAULT;
@@ -98,10 +99,11 @@
PlaySound(sound_data, NULL, flags);
- return;
+ /* #### Error handling? */
+ return 1;
}
-void play_sound_data (unsigned char *data, int length, int volume)
+int play_sound_data (unsigned char *data, int length, int volume)
{
- play_sound_data_1 (data, length, volume, TRUE);
+ return play_sound_data_1 (data, length, volume, TRUE);
}
Index: sgiplay.c
===================================================================
RCS file: /usr/CVSroot/XEmacs/xemacs/src/sgiplay.c,v
retrieving revision 1.3.2.2
diff -u -r1.3.2.2 sgiplay.c
--- sgiplay.c 2000/02/16 02:06:35 1.3.2.2
+++ sgiplay.c 2000/02/21 20:01:40
@@ -23,6 +23,7 @@
#include <config.h>
#include "lisp.h"
+#include "nativesound.h"
#include <string.h>
#include <sys/file.h>
@@ -91,14 +92,7 @@
#define DEFAULT_CHANNEL_COUNT 1
#define DEFAULT_FORMAT AFmulaw8
-/* Exports */
-/* all compilers on machines that have the SGI audio library
- understand prototypes, right? */
-
-extern void play_sound_file (char *, int);
-extern void play_sound_data (unsigned char *, int, int);
-
/* Data structures */
/* an AudioContext describes everything we want to know about how a
@@ -263,7 +257,7 @@
return Qnil;
}
-void
+int
play_sound_data (unsigned char *data, int length, int volume)
{
int count = specpdl_depth ();
@@ -271,10 +265,12 @@
ac = audio_initialize (data, length, volume);
if (ac == (AudioContext) 0)
- return;
+ return 0;
play_internal (data, length, ac);
drain_audio_port (ac);
unbind_to (count, Qnil);
+
+ return 1;
}
static AudioContext
Index: signal.c
===================================================================
RCS file: /usr/CVSroot/XEmacs/xemacs/src/signal.c,v
retrieving revision 1.12.2.1
diff -u -r1.12.2.1 signal.c
--- signal.c 1998/12/05 16:56:26 1.12.2.1
+++ signal.c 2000/02/21 20:01:40
@@ -344,7 +344,7 @@
new_it.it_interval.tv_sec = 0;
new_it.it_interval.tv_usec = 0;
setitimer (ITIMER_REAL, &new_it, &old_it);
-
+
/* Never return zero if there was a timer outstanding. */
return old_it.it_value.tv_sec + (old_it.it_value.tv_usec > 0 ? 1 : 0);
}
Index: sound.c
===================================================================
RCS file: /usr/CVSroot/XEmacs/xemacs/src/sound.c,v
retrieving revision 1.9.2.11
diff -u -r1.9.2.11 sound.c
--- sound.c 2000/02/16 02:06:53 1.9.2.11
+++ sound.c 2000/02/21 20:01:41
@@ -58,12 +58,8 @@
Lisp_Object Vnative_sound_only_on_console;
Lisp_Object Q_volume, Q_pitch, Q_duration, Q_sound;
-/* These are defined in the appropriate file (sunplay.c, sgiplay.c,
- or hpplay.c). */
+#include "nativeplay.h"
-extern void play_sound_file (char *name, int volume);
-extern void play_sound_data (unsigned char *data, int length, int volume);
-
#ifdef HAVE_NAS_SOUND
extern int nas_play_sound_file (char *name, int volume);
extern int nas_play_sound_data (unsigned char *data, int length, int volume);
@@ -139,11 +135,17 @@
if (DEVICE_CONNECTED_TO_ESD_P (d))
{
char *fileext;
+ int result;
TO_EXTERNAL_FORMAT (LISP_STRING, file,
C_STRING_ALLOCA, fileext,
Qfile_name);
- if (esd_play_sound_file (fileext, vol))
+
+ /* #### ESD uses alarm(). But why should we also stop SIGIO? */
+ stop_interrupts ();
+ result = esd_play_sound_file (fileext, vol);
+ start_interrupts ();
+ if (result)
return Qnil;
}
#endif /* HAVE_ESD_SOUND */
@@ -277,7 +279,7 @@
/* variable `sound' is anything that can be a cdr in sound-alist */
Lisp_Object new_volume, pitch, duration, data;
int loop_count = 0;
- int vol, pit, dur;
+ int vol, pit, dur, succes;
struct device *d = decode_device (device);
/* NOTE! You'd better not signal an error in here. */
@@ -336,8 +338,14 @@
TO_EXTERNAL_FORMAT (LISP_STRING, sound, ALLOCA, (soundext, soundextlen),
Qbinary);
- if (esd_play_sound_data (soundext, soundextlen, vol))
- return Qnil;
+
+ /* #### ESD uses alarm(). But why should we also stop SIGIO? */
+ stop_interrupts ();
+ succes = esd_play_sound_data (soundext, soundextlen, vol);
+ start_interrupts ();
+ QUIT;
+ if(succes)
+ return Qnil;
}
#endif /* HAVE_ESD_SOUND */
@@ -353,10 +361,11 @@
Qbinary);
/* The sound code doesn't like getting SIGIO interrupts. Unix sucks! */
stop_interrupts ();
- play_sound_data ((unsigned char*)soundext, soundextlen, vol);
+ succes = play_sound_data ((unsigned char*)soundext, soundextlen, vol);
start_interrupts ();
QUIT;
- return Qnil;
+ if (succes)
+ return Qnil;
}
#endif /* HAVE_NATIVE_SOUND */
Index: sunplay.c
===================================================================
RCS file: /usr/CVSroot/XEmacs/xemacs/src/sunplay.c,v
retrieving revision 1.5.2.3
diff -u -r1.5.2.3 sunplay.c
--- sunplay.c 2000/02/16 02:07:24 1.5.2.3
+++ sunplay.c 2000/02/21 20:01:41
@@ -41,6 +41,7 @@
# include "lisp.h"
# include "sysdep.h"
# include <errno.h>
+# include "nativesound.h"
#include "syssignal.h"
# define perror(string) \
message("audio: %s, %s ", string, strerror (errno))
@@ -61,9 +62,6 @@
static double old_volume;
static Audio_hdr dev_hdr;
-void play_sound_file (char *name, int volume);
-void play_sound_data (unsigned char *data, int length, int volume);
-
static int
init_device (int volume, unsigned char *data, int fd,
unsigned int *header_length)
@@ -227,15 +225,16 @@
}
-void
+int
play_sound_data (unsigned char *data, int length, int volume)
{
int wrtn, start = 0;
unsigned int ilen;
+ int result = 0;
audio_fd = -1;
- if (length == 0) return;
+ if (length == 0) return 0;
/* this is just to get a better error message */
if (strncmp (".snd\0", (char *) data, 4))
@@ -251,10 +250,7 @@
audio_fd = audio_open ();
if (audio_fd < 0)
- {
- perror ("open /dev/audio");
- return;
- }
+ return 0;
/* where to find the proto for signal()... */
sighup_handler = (SIGTYPE (*) (int)) signal (SIGHUP, sighandler);
@@ -292,6 +288,8 @@
goto END_OF_PLAY;
}
+ result = 1;
+
END_OF_PLAY:
if (audio_fd > 0)
@@ -302,6 +300,8 @@
signal (SIGHUP, sighup_handler);
signal (SIGINT, sigint_handler);
+
+ return result;
}
/* #### sigcontext doesn't exist in Solaris. This should be updated
--- nativesound.h.orig Mon Feb 21 21:06:17 2000
+++ nativesound.h Mon Feb 7 20:23:59 2000
@@ -0,0 +1,27 @@
+/* Sound functions.
+ Copyright (C) 2000 Free Software Foundation, Inc.
+
+This file is part of XEmacs.
+
+XEmacs is free software; you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by the
+Free Software Foundation; either version 2, or (at your option) any
+later version.
+
+XEmacs is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with XEmacs; see the file COPYING. If not, write to
+the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+Boston, MA 02111-1307, USA. */
+
+/* Synched up with: Not in FSF. */
+
+/* These are defined in the appropriate file (sunplay.c, sgiplay.c,
+ or hpplay.c). */
+
+void play_sound_file (char *name, int volume);
+int play_sound_data (unsigned char *data, int length, int volume);