annotate src/sound.c @ 404:2f8bb876ab1d r21-2-32

Import from CVS: tag r21-2-32
author cvs
date Mon, 13 Aug 2007 11:16:07 +0200
parents 74fd4e045ea6
children b8cc9ab3f761
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1 /* Sound functions.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2 Copyright (C) 1992, 1993, 1994 Lucid Inc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3 Copyright (C) 1994, 1995 Free Software Foundation, Inc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5 This file is part of XEmacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7 XEmacs is free software; you can redistribute it and/or modify it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8 under the terms of the GNU General Public License as published by the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9 Free Software Foundation; either version 2, or (at your option) any
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10 later version.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12 XEmacs is distributed in the hope that it will be useful, but WITHOUT
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15 for more details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17 You should have received a copy of the GNU General Public License
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18 along with XEmacs; see the file COPYING. If not, write to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20 Boston, MA 02111-1307, USA. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22 /* Synched up with: Not in FSF. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24 /* Originally written by Jamie Zawinski.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25 Hacked on quite a bit by various others. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27 #include <config.h>
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
28 #include <time.h>
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29 #include "lisp.h"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31 #include "buffer.h"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 #ifdef HAVE_X_WINDOWS
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 #include "console-x.h"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36 #include "device.h"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 #include "redisplay.h"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 #include "sysdep.h"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 265
diff changeset
40 #ifdef HAVE_UNISTD_H
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 265
diff changeset
41 #include <unistd.h>
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 265
diff changeset
42 #endif
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 265
diff changeset
43
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 #ifdef HAVE_NATIVE_SOUND
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 # include <netdb.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
48 #ifdef HAVE_ESD_SOUND
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
49 extern int esd_play_sound_file (char *file, int vol);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
50 extern int esd_play_sound_data (unsigned char *data, size_t length, int vol);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
51 # define DEVICE_CONNECTED_TO_ESD_P(x) 1 /* FIXME: better check */
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
52 #endif
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
53
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 int bell_volume;
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
55 int bell_inhibit_time;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 Lisp_Object Vsound_alist;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 Lisp_Object Vsynchronous_sounds;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 Lisp_Object Vnative_sound_only_on_console;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 Lisp_Object Q_volume, Q_pitch, Q_duration, Q_sound;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 /* These are defined in the appropriate file (sunplay.c, sgiplay.c,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 or hpplay.c). */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64 extern void play_sound_file (char *name, int volume);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 extern void play_sound_data (unsigned char *data, int length, int volume);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 #ifdef HAVE_NAS_SOUND
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 extern int nas_play_sound_file (char *name, int volume);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 extern int nas_play_sound_data (unsigned char *data, int length, int volume);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 extern int nas_wait_for_sounds (void);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 extern char *nas_init_play (Display *);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73 Lisp_Object Qnas;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
76 DEFUN ("play-sound-file", Fplay_sound_file, 1, 3, "fSound file name: ", /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 Play the named sound file on DEVICE's speaker at the specified volume
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 265
diff changeset
78 \(0-100, default specified by the `bell-volume' variable).
384
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 380
diff changeset
79 On Unix machines the sound file must be in the Sun/NeXT U-LAW format
396
6719134a07c2 Import from CVS: tag r21-2-13
cvs
parents: 384
diff changeset
80 except under Linux where WAV files are also supported. On Microsoft
384
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 380
diff changeset
81 Windows the sound file must be in WAV format.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 DEVICE defaults to the selected device.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
83 */
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 44
diff changeset
84 (file, volume, device))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 {
116
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 70
diff changeset
86 /* This function can call lisp */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 int vol;
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
88 #if defined (HAVE_NATIVE_SOUND) || defined (HAVE_NAS_SOUND) \
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
89 || defined (HAVE_ESD_SOUND)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 struct device *d = decode_device (device);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 #endif
116
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 70
diff changeset
92 struct gcpro gcpro1;
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 70
diff changeset
93
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 CHECK_STRING (file);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 if (NILP (volume))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 vol = bell_volume;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 CHECK_INT (volume);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 vol = XINT (volume);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102
116
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 70
diff changeset
103 GCPRO1 (file);
245
51092a27c943 Import from CVS: tag r20-5b21
cvs
parents: 233
diff changeset
104 while (1)
233
52952cbfc5b5 Import from CVS: tag r20-5b15
cvs
parents: 120
diff changeset
105 {
245
51092a27c943 Import from CVS: tag r20-5b21
cvs
parents: 233
diff changeset
106 file = Fexpand_file_name (file, Qnil);
51092a27c943 Import from CVS: tag r20-5b21
cvs
parents: 233
diff changeset
107 if (!NILP(Ffile_readable_p (file)))
51092a27c943 Import from CVS: tag r20-5b21
cvs
parents: 233
diff changeset
108 break;
51092a27c943 Import from CVS: tag r20-5b21
cvs
parents: 233
diff changeset
109 else
51092a27c943 Import from CVS: tag r20-5b21
cvs
parents: 233
diff changeset
110 {
51092a27c943 Import from CVS: tag r20-5b21
cvs
parents: 233
diff changeset
111 /* #### This is crockish. It might be a better idea to try
51092a27c943 Import from CVS: tag r20-5b21
cvs
parents: 233
diff changeset
112 to open the file, and use report_file_error() if it
51092a27c943 Import from CVS: tag r20-5b21
cvs
parents: 233
diff changeset
113 fails. --hniksic */
51092a27c943 Import from CVS: tag r20-5b21
cvs
parents: 233
diff changeset
114 if (NILP (Ffile_exists_p (file)))
265
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents: 245
diff changeset
115 file =
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents: 245
diff changeset
116 signal_simple_continuable_error ("File does not exist", file);
245
51092a27c943 Import from CVS: tag r20-5b21
cvs
parents: 233
diff changeset
117 else
265
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents: 245
diff changeset
118 file =
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents: 245
diff changeset
119 signal_simple_continuable_error ("File is unreadable", file);
245
51092a27c943 Import from CVS: tag r20-5b21
cvs
parents: 233
diff changeset
120 }
233
52952cbfc5b5 Import from CVS: tag r20-5b15
cvs
parents: 120
diff changeset
121 }
116
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 70
diff changeset
122 UNGCPRO;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124 #ifdef HAVE_NAS_SOUND
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125 if (DEVICE_CONNECTED_TO_NAS_P (d))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127 char *fileext;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
129 TO_EXTERNAL_FORMAT (LISP_STRING, file,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
130 C_STRING_ALLOCA, fileext,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
131 Qfile_name);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132 /* #### NAS code should allow specification of a device. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133 if (nas_play_sound_file (fileext, vol))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134 return Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 #endif /* HAVE_NAS_SOUND */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
138 #ifdef HAVE_ESD_SOUND
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
139 if (DEVICE_CONNECTED_TO_ESD_P (d))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
140 {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
141 char *fileext;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
142
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
143 TO_EXTERNAL_FORMAT (LISP_STRING, file,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
144 C_STRING_ALLOCA, fileext,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
145 Qfile_name);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
146 if (esd_play_sound_file (fileext, vol))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
147 return Qnil;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
148 }
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
149 #endif /* HAVE_ESD_SOUND */
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
150
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151 #ifdef HAVE_NATIVE_SOUND
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152 if (NILP (Vnative_sound_only_on_console) || DEVICE_ON_CONSOLE_P (d))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153 {
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
154 const char *fileext;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
156 TO_EXTERNAL_FORMAT (LISP_STRING, file,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
157 C_STRING_ALLOCA, fileext,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
158 Qfile_name);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159 /* The sound code doesn't like getting SIGIO interrupts.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160 Unix sucks! */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161 stop_interrupts ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162 play_sound_file ((char *) fileext, vol);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163 start_interrupts ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164 QUIT;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166 #endif /* HAVE_NATIVE_SOUND */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168 return Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172 parse_sound_alist_elt (Lisp_Object elt,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173 Lisp_Object *volume,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174 Lisp_Object *pitch,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175 Lisp_Object *duration,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176 Lisp_Object *sound)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178 *volume = Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179 *pitch = Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180 *duration = Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181 *sound = Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182 if (! CONSP (elt))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183 return;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 /* The things we do for backward compatibility...
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186 I wish I had just forced this to be a plist to begin with.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189 if (SYMBOLP (elt) || STRINGP (elt)) /* ( name . <sound> ) */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191 *sound = elt;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193 else if (!CONSP (elt))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195 return;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197 else if (NILP (XCDR (elt)) && /* ( name <sound> ) */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198 (SYMBOLP (XCAR (elt)) ||
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199 STRINGP (XCAR (elt))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201 *sound = XCAR (elt);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203 else if (INT_OR_FLOATP (XCAR (elt)) && /* ( name <vol> . <sound> ) */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204 (SYMBOLP (XCDR (elt)) ||
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205 STRINGP (XCDR (elt))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207 *volume = XCAR (elt);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208 *sound = XCDR (elt);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210 else if (INT_OR_FLOATP (XCAR (elt)) && /* ( name <vol> <sound> ) */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211 CONSP (XCDR (elt)) &&
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212 NILP (XCDR (XCDR (elt))) &&
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213 (SYMBOLP (XCAR (XCDR (elt))) ||
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214 STRINGP (XCAR (XCDR (elt)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216 *volume = XCAR (elt);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217 *sound = XCAR (XCDR (elt));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219 else if ((SYMBOLP (XCAR (elt)) || /* ( name <sound> . <vol> ) */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220 STRINGP (XCAR (elt))) &&
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221 INT_OR_FLOATP (XCDR (elt)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223 *sound = XCAR (elt);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224 *volume = XCDR (elt);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226 #if 0 /* this one is ambiguous with the plist form */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227 else if ((SYMBOLP (XCAR (elt)) || /* ( name <sound> <vol> ) */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228 STRINGP (XCAR (elt))) &&
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229 CONSP (XCDR (elt)) &&
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230 NILP (XCDR (XCDR (elt))) &&
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231 INT_OR_FLOATP (XCAR (XCDR (elt))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233 *sound = XCAR (elt);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234 *volume = XCAR (XCDR (elt));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236 #endif /* 0 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237 else /* ( name [ keyword <value> ]* ) */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239 while (CONSP (elt))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241 Lisp_Object key, val;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242 key = XCAR (elt);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243 val = XCDR (elt);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244 if (!CONSP (val))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245 return;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246 elt = XCDR (val);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247 val = XCAR (val);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248 if (EQ (key, Q_volume))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250 if (INT_OR_FLOATP (val)) *volume = val;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252 else if (EQ (key, Q_pitch))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254 if (INT_OR_FLOATP (val)) *pitch = val;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255 if (NILP (*sound)) *sound = Qt;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257 else if (EQ (key, Q_duration))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259 if (INT_OR_FLOATP (val)) *duration = val;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260 if (NILP (*sound)) *sound = Qt;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262 else if (EQ (key, Q_sound))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264 if (SYMBOLP (val) || STRINGP (val)) *sound = val;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
265 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
266 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
267 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
269
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
270 DEFUN ("play-sound", Fplay_sound, 1, 3, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
271 Play a sound of the provided type.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
272 See the variable `sound-alist'.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
273 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
274 (sound, volume, device))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
275 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
276 int looking_for_default = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
277 /* variable `sound' is anything that can be a cdr in sound-alist */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
278 Lisp_Object new_volume, pitch, duration, data;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
279 int loop_count = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
280 int vol, pit, dur;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
281 struct device *d = decode_device (device);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
282
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
283 /* NOTE! You'd better not signal an error in here. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
284
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
285
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
286 try_it_again:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
287 while (1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
288 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
289 if (SYMBOLP (sound))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
290 sound = Fcdr (Fassq (sound, Vsound_alist));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
291 parse_sound_alist_elt (sound, &new_volume, &pitch, &duration, &data);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
292 sound = data;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
293 if (NILP (volume)) volume = new_volume;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
294 if (EQ (sound, Qt) || EQ (sound, Qnil) || STRINGP (sound))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
295 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
296 if (loop_count++ > 500) /* much bogosity has occurred */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
297 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
298 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
299
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
300 if (NILP (sound) && !looking_for_default)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
301 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
302 looking_for_default = 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
303 loop_count = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
304 sound = Qdefault;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
305 goto try_it_again;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
306 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
307
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 265
diff changeset
308
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 265
diff changeset
309 vol = (INT_OR_FLOATP (volume) ? (int) XFLOATINT (volume) : bell_volume);
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 265
diff changeset
310 pit = (INT_OR_FLOATP (pitch) ? (int) XFLOATINT (pitch) : -1);
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 265
diff changeset
311 dur = (INT_OR_FLOATP (duration) ? (int) XFLOATINT (duration) : -1);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
312
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
313 /* If the sound is a string, and we're connected to Nas, do that.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
314 Else if the sound is a string, and we're on console, play it natively.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
315 Else just beep.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
316 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
317 #ifdef HAVE_NAS_SOUND
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
318 if (DEVICE_CONNECTED_TO_NAS_P (d) && STRINGP (sound))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
319 {
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
320 const Extbyte *soundext;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
321 Extcount soundextlen;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
322
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
323 TO_EXTERNAL_FORMAT (LISP_STRING, sound,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
324 ALLOCA, (soundext, soundextlen),
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
325 Qbinary);
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 265
diff changeset
326 if (nas_play_sound_data ((unsigned char*)soundext, soundextlen, vol))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
327 return Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
328 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
329 #endif /* HAVE_NAS_SOUND */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
330
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
331 #ifdef HAVE_ESD_SOUND
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
332 if (DEVICE_CONNECTED_TO_ESD_P (d) && STRINGP (sound))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
333 {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
334 Extbyte *soundext;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
335 Extcount soundextlen;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
336
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
337 TO_EXTERNAL_FORMAT (LISP_STRING, sound, ALLOCA, (soundext, soundextlen),
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
338 Qbinary);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
339 if (esd_play_sound_data (soundext, soundextlen, vol))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
340 return Qnil;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
341 }
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
342 #endif /* HAVE_ESD_SOUND */
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
343
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
344 #ifdef HAVE_NATIVE_SOUND
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
345 if ((NILP (Vnative_sound_only_on_console) || DEVICE_ON_CONSOLE_P (d))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
346 && STRINGP (sound))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
347 {
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
348 const Extbyte *soundext;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
349 Extcount soundextlen;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
350
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
351 TO_EXTERNAL_FORMAT (LISP_STRING, sound,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
352 ALLOCA, (soundext, soundextlen),
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
353 Qbinary);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
354 /* The sound code doesn't like getting SIGIO interrupts. Unix sucks! */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
355 stop_interrupts ();
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 265
diff changeset
356 play_sound_data ((unsigned char*)soundext, soundextlen, vol);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
357 start_interrupts ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
358 QUIT;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
359 return Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
360 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
361 #endif /* HAVE_NATIVE_SOUND */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
362
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
363 DEVMETH (d, ring_bell, (d, vol, pit, dur));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
364 return Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
365 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
366
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
367 DEFUN ("device-sound-enabled-p", Fdevice_sound_enabled_p, 0, 1, 0, /*
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 265
diff changeset
368 Return t if DEVICE is able to play sound. Defaults to selected device.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
369 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
370 (device))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
371 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
372 #ifdef HAVE_NAS_SOUND
396
6719134a07c2 Import from CVS: tag r21-2-13
cvs
parents: 384
diff changeset
373 if (DEVICE_CONNECTED_TO_NAS_P (decode_device (device)))
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 265
diff changeset
374 return Qt;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
375 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
376 #ifdef HAVE_NATIVE_SOUND
396
6719134a07c2 Import from CVS: tag r21-2-13
cvs
parents: 384
diff changeset
377 if (DEVICE_ON_CONSOLE_P (decode_device (device)))
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 265
diff changeset
378 return Qt;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
379 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
380 return Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
381 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
382
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
383 DEFUN ("ding", Fding, 0, 3, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
384 Beep, or flash the frame.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
385 Also, unless an argument is given,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
386 terminate any keyboard macro currently executing.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
387 When called from lisp, the second argument is what sound to make, and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
388 the third argument is the device to make it in (defaults to the selected
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
389 device).
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
390 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
391 (arg, sound, device))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
392 {
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
393 static time_t last_bell_time;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
394 static struct device *last_bell_device;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
395 time_t now;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
396 struct device *d = decode_device (device);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
397
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
398 XSETDEVICE (device, d);
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
399 now = time (0);
245
51092a27c943 Import from CVS: tag r20-5b21
cvs
parents: 233
diff changeset
400
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
401 if (NILP (arg) && !NILP (Vexecuting_macro))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
402 /* Stop executing a keyboard macro. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
403 error ("Keyboard macro terminated by a command ringing the bell");
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
404
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
405 if (d == last_bell_device && now-last_bell_time < bell_inhibit_time)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
406 return Qnil;
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
407 else if (!NILP (Vvisible_bell) && DEVMETH (d, flash, (d)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
408 ;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
409 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
410 Fplay_sound (sound, Qnil, device);
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
411
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
412 last_bell_time = now;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
413 last_bell_device = d;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
414 return Qnil;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
415 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
416
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
417 DEFUN ("wait-for-sounds", Fwait_for_sounds, 0, 1, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
418 Wait for all sounds to finish playing on DEVICE.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
419 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
420 (device))
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 44
diff changeset
421
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
422 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
423 #ifdef HAVE_NAS_SOUND
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
424 struct device *d = decode_device (device);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
425 if (DEVICE_CONNECTED_TO_NAS_P (d))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
426 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
427 /* #### somebody fix this to be device-dependent. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
428 nas_wait_for_sounds ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
429 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
430 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
431 return Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
432 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
433
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
434 DEFUN ("connected-to-nas-p", Fconnected_to_nas_p, 0, 1, 0, /*
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 265
diff changeset
435 Return t if connected to NAS server for sounds on DEVICE.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
436 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
437 (device))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
438 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
439 #ifdef HAVE_NAS_SOUND
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 265
diff changeset
440 return DEVICE_CONNECTED_TO_NAS_P (decode_device (device)) ? Qt : Qnil;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
441 #else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
442 return Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
443 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
444 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
445 #ifdef HAVE_NAS_SOUND
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
446
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
447 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
448 init_nas_sound (struct device *d)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
449 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
450 #ifdef HAVE_X_WINDOWS
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
451 if (DEVICE_X_P (d))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
452 {
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
453 char *err_message = nas_init_play (DEVICE_X_DISPLAY (d));
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
454 DEVICE_CONNECTED_TO_NAS_P (d) = !err_message;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
455 /* Print out the message? */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
456 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
457 #endif /* HAVE_X_WINDOWS */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
458 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
459
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
460 #endif /* HAVE_NAS_SOUND */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
461
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
462 #ifdef HAVE_NATIVE_SOUND
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
463
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
464 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
465 init_native_sound (struct device *d)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
466 {
265
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents: 245
diff changeset
467 if (DEVICE_TTY_P (d) || DEVICE_STREAM_P (d) || DEVICE_MSWINDOWS_P(d))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
468 DEVICE_ON_CONSOLE_P (d) = 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
469 #ifdef HAVE_X_WINDOWS
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
470 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
471 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
472 /* When running on a machine with native sound support, we cannot use
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
473 digitized sounds as beeps unless emacs is running on the same machine
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
474 that $DISPLAY points to, and $DISPLAY points to frame 0 of that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
475 machine.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
476 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
477
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
478 Display *display = DEVICE_X_DISPLAY (d);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
479 char *dpy = DisplayString (display);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
480 char *tail = (char *) strchr (dpy, ':');
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
481 if (! tail ||
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
482 strncmp (tail, ":0", 2))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
483 DEVICE_ON_CONSOLE_P (d) = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
484 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
485 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
486 char dpyname[255], localname[255];
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
487
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
488 /* some systems can't handle SIGIO or SIGALARM in gethostbyname. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
489 stop_interrupts ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
490 strncpy (dpyname, dpy, tail-dpy);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
491 dpyname [tail-dpy] = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
492 if (!*dpyname ||
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
493 !strcmp (dpyname, "unix") ||
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
494 !strcmp (dpyname, "localhost"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
495 DEVICE_ON_CONSOLE_P (d) = 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
496 else if (gethostname (localname, sizeof (localname)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
497 DEVICE_ON_CONSOLE_P (d) = 0; /* can't find hostname? */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
498 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
499 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
500 /* We have to call gethostbyname() on the result of gethostname()
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 371
diff changeset
501 because the two aren't guaranteed to be the same name for the
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
502 same host: on some losing systems, one is a FQDN and the other
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
503 is not. Here in the wide wonderful world of Unix it's rocket
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
504 science to obtain the local hostname in a portable fashion.
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 265
diff changeset
505
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
506 And don't forget, gethostbyname() reuses the structure it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
507 returns, so we have to copy the fucker before calling it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
508 again.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
509
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
510 Thank you master, may I have another.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
511 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
512 struct hostent *h = gethostbyname (dpyname);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
513 if (!h)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
514 DEVICE_ON_CONSOLE_P (d) = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
515 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
516 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
517 char hn [255];
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
518 struct hostent *l;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
519 strcpy (hn, h->h_name);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
520 l = gethostbyname (localname);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
521 DEVICE_ON_CONSOLE_P (d) = (l && !(strcmp (l->h_name, hn)));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
522 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
523 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
524 start_interrupts ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
525 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
526 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
527 #endif /* HAVE_X_WINDOWS */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
528 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
529
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
530 #endif /* HAVE_NATIVE_SOUND */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
531
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
532 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
533 init_device_sound (struct device *d)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
534 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
535 #ifdef HAVE_NAS_SOUND
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
536 init_nas_sound (d);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
537 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
538
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
539 #ifdef HAVE_NATIVE_SOUND
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
540 init_native_sound (d);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
541 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
542 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
543
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
544 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
545 syms_of_sound (void)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
546 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
547 defkeyword (&Q_volume, ":volume");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
548 defkeyword (&Q_pitch, ":pitch");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
549 defkeyword (&Q_duration, ":duration");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
550 defkeyword (&Q_sound, ":sound");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
551
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
552 #ifdef HAVE_NAS_SOUND
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
553 defsymbol (&Qnas, "nas");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
554 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
555
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
556 DEFSUBR (Fplay_sound_file);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
557 DEFSUBR (Fplay_sound);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
558 DEFSUBR (Fding);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
559 DEFSUBR (Fwait_for_sounds);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
560 DEFSUBR (Fconnected_to_nas_p);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
561 DEFSUBR (Fdevice_sound_enabled_p);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
562 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
563
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
564
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
565 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
566 vars_of_sound (void)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
567 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
568 #ifdef HAVE_NATIVE_SOUND
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
569 Fprovide (intern ("native-sound"));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
570 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
571 #ifdef HAVE_NAS_SOUND
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
572 Fprovide (intern ("nas-sound"));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
573 #endif
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
574 #ifdef HAVE_ESD_SOUND
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
575 Fprovide (intern ("esd-sound"));
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
576 #endif
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
577
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
578 DEFVAR_INT ("bell-volume", &bell_volume /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
579 *How loud to be, from 0 to 100.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
580 */ );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
581 bell_volume = 50;
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
582
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
583 DEFVAR_INT ("bell-inhibit-time", &bell_inhibit_time /*
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
584 *Don't ring the bell on the same device more than once within this many seconds.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
585 */ );
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
586 bell_inhibit_time = 0;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
587
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
588 DEFVAR_LISP ("sound-alist", &Vsound_alist /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
589 An alist associating names with sounds.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
590 When `beep' or `ding' is called with one of the name symbols, the associated
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
591 sound will be generated instead of the standard beep.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
592
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
593 Each element of `sound-alist' is a list describing a sound.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
594 The first element of the list is the name of the sound being defined.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
595 Subsequent elements of the list are alternating keyword/value pairs:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
596
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
597 Keyword: Value:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
598 ------- -----
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
599 sound A string of raw sound data, or the name of another sound to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
600 play. The symbol `t' here means use the default X beep.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
601 volume An integer from 0-100, defaulting to `bell-volume'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
602 pitch If using the default X beep, the pitch (Hz) to generate.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
603 duration If using the default X beep, the duration (milliseconds).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
604
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
605 For compatibility, elements of `sound-alist' may also be:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
606
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
607 ( sound-name . <sound> )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
608 ( sound-name <volume> <sound> )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
609
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
610 You should probably add things to this list by calling the function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
611 load-sound-file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
612
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
613 Caveats:
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
614 - XEmacs must be built with sound support for your system. Not all
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
615 systems support sound.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
616
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
617 - The pitch, duration, and volume options are available everywhere, but
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
618 many X servers ignore the `pitch' option.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
619
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
620 The following beep-types are used by emacs itself:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
621
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
622 auto-save-error when an auto-save does not succeed
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
623 command-error when the emacs command loop catches an error
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
624 undefined-key when you type a key that is undefined
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
625 undefined-click when you use an undefined mouse-click combination
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
626 no-completion during completing-read
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
627 y-or-n-p when you type something other than 'y' or 'n'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
628 yes-or-no-p when you type something other than 'yes' or 'no'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
629 default used when nothing else is appropriate.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
630
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
631 Other lisp packages may use other beep types, but these are the ones that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
632 the C kernel of Emacs uses.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
633 */ );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
634 Vsound_alist = Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
635
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
636 DEFVAR_LISP ("synchronous-sounds", &Vsynchronous_sounds /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
637 Play sounds synchronously, if non-nil.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
638 Only applies if NAS is used and supports asynchronous playing
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
639 of sounds. Otherwise, sounds are always played synchronously.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
640 */ );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
641 Vsynchronous_sounds = Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
642
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
643 DEFVAR_LISP ("native-sound-only-on-console", &Vnative_sound_only_on_console /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
644 Non-nil value means play sounds only if XEmacs is running
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
645 on the system console.
371
cc15677e0335 Import from CVS: tag r21-2b1
cvs
parents: 367
diff changeset
646 Nil means always always play sounds, even if running on a non-console tty
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
647 or a secondary X display.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
648
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
649 This variable only applies to native sound support.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
650 */ );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
651 Vnative_sound_only_on_console = Qt;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
652
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
653 #if defined (HAVE_NATIVE_SOUND) && defined (hp9000s800)
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 272
diff changeset
654 {
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 272
diff changeset
655 void vars_of_hpplay (void);
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 272
diff changeset
656 vars_of_hpplay ();
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 272
diff changeset
657 }
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
658 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
659 }