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