Mercurial > hg > xemacs-beta
comparison src/sound.c @ 563:183866b06e0b
[xemacs-hg @ 2001-05-24 07:50:48 by ben]
Makefile.in.in, abbrev.c, alloc.c, buffer.c, bytecode.c, callint.c, callproc.c, casetab.c, chartab.c, cmdloop.c, cmds.c, console-msw.c, console-msw.h, console-stream.c, console-tty.c, console-x.c, console.c, data.c, database.c, debug.c, device-gtk.c, device-msw.c, device-tty.c, device-x.c, device.c, dialog-gtk.c, dialog-msw.c, dialog-x.c, dialog.c, dired-msw.c, dired.c, doc.c, doprnt.c, dragdrop.c, editfns.c, eldap.c, eldap.h, elhash.c, emacs-widget-accessors.c, emacs.c, emodules.c, esd.c, eval.c, event-Xt.c, event-gtk.c, event-msw.c, event-stream.c, events.c, extents.c, faces.c, file-coding.c, fileio.c, filelock.c, floatfns.c, fns.c, font-lock.c, frame-gtk.c, frame-x.c, frame.c, general-slots.h, glade.c, glyphs-gtk.c, glyphs-msw.c, glyphs-widget.c, glyphs-x.c, glyphs.c, glyphs.h, gpmevent.c, gui-gtk.c, gui-x.c, gui.c, gutter.c, hpplay.c, indent.c, input-method-xlib.c, insdel.c, intl.c, keymap.c, libsst.c, libsst.h, linuxplay.c, lisp.h, lread.c, lstream.c, lstream.h, macros.c, marker.c, md5.c, menubar-gtk.c, menubar-msw.c, menubar-x.c, menubar.c, minibuf.c, miscplay.c, miscplay.h, mule-ccl.c, mule-charset.c, mule-wnnfns.c, mule.c, nas.c, ntplay.c, ntproc.c, objects-gtk.c, objects-msw.c, objects-x.c, objects.c, postgresql.c, print.c, process-nt.c, process-unix.c, process.c, ralloc.c, rangetab.c, redisplay.c, scrollbar.c, search.c, select-gtk.c, select-x.c, select.c, sgiplay.c, sheap.c, sound.c, specifier.c, sunplay.c, symbols.c, symeval.h, symsinit.h, syntax.c, sysdep.c, toolbar-msw.c, toolbar.c, tooltalk.c, ui-byhand.c, ui-gtk.c, undo.c, unexaix.c, unexapollo.c, unexconvex.c, unexec.c, widget.c, win32.c, window.c:
-- defsymbol -> DEFSYMBOL.
-- add an error type to all errors.
-- eliminate the error functions in eval.c that let you just
use Qerror as the type.
-- redo the error API to be more consistent, sensibly named,
and easier to use.
-- redo the error hierarchy somewhat. create new errors:
structure-formation-error, gui-error, invalid-constant,
stack-overflow, out-of-memory, process-error, network-error,
sound-error, printing-unreadable-object, base64-conversion-
error; coding-system-error renamed to text-conversion error;
some others.
-- fix Mule problems in error strings in emodules.c, tooltalk.c.
-- fix error handling in mswin open-network-stream.
-- Mule-ize all sound files and clean up the headers.
-- nativesound.h -> sound.h and used for all sound files.
-- move some shared stuff into glyphs-shared.c: first attempt
at eliminating some of the massive GTK code duplication.
xemacs.mak: add glyphs-shared.c.
xemacs-faq.texi: document how to debug X errors
subr.el: fix doc string to reflect reality
author | ben |
---|---|
date | Thu, 24 May 2001 07:51:33 +0000 |
parents | c33ae14dd6d0 |
children | 13e3d7ae7155 |
comparison
equal
deleted
inserted
replaced
562:c775bd016b32 | 563:183866b06e0b |
---|---|
19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
20 Boston, MA 02111-1307, USA. */ | 20 Boston, MA 02111-1307, USA. */ |
21 | 21 |
22 /* Synched up with: Not in FSF. */ | 22 /* Synched up with: Not in FSF. */ |
23 | 23 |
24 /* This file Mule-ized by Ben Wing, 5-15-01. */ | |
25 | |
24 /* Originally written by Jamie Zawinski. | 26 /* Originally written by Jamie Zawinski. |
25 Hacked on quite a bit by various others. */ | 27 Hacked on quite a bit by various others. */ |
26 | 28 |
27 #include <config.h> | 29 #include <config.h> |
28 #include <time.h> | 30 #include <time.h> |
30 | 32 |
31 #include "buffer.h" | 33 #include "buffer.h" |
32 #ifdef HAVE_X_WINDOWS | 34 #ifdef HAVE_X_WINDOWS |
33 #include "console-x.h" | 35 #include "console-x.h" |
34 #endif | 36 #endif |
35 | |
36 #include "device.h" | 37 #include "device.h" |
37 #include "redisplay.h" | 38 #include "redisplay.h" |
39 #include "sound.h" | |
40 | |
38 #include "sysdep.h" | 41 #include "sysdep.h" |
39 | 42 |
40 #include "sysfile.h" | 43 #include "sysfile.h" |
41 | 44 |
42 #ifdef HAVE_NATIVE_SOUND | 45 #ifdef HAVE_NATIVE_SOUND |
43 # include "sysproc.h" | 46 # include "sysproc.h" |
44 # include "nativesound.h" | |
45 #endif | 47 #endif |
46 | 48 |
47 #ifdef HAVE_ESD_SOUND | 49 #ifdef HAVE_ESD_SOUND |
48 extern int esd_play_sound_file (char *file, int vol); | 50 extern int esd_play_sound_file (Extbyte *file, int vol); |
49 extern int esd_play_sound_data (unsigned char *data, size_t length, int vol); | 51 extern int esd_play_sound_data (UChar_Binary *data, size_t length, int vol); |
50 # define DEVICE_CONNECTED_TO_ESD_P(x) 1 /* FIXME: better check */ | 52 # define DEVICE_CONNECTED_TO_ESD_P(x) 1 /* #### better check */ |
51 #endif | 53 #endif |
52 | 54 |
53 Fixnum bell_volume; | 55 Fixnum bell_volume; |
54 Fixnum bell_inhibit_time; | 56 Fixnum bell_inhibit_time; |
55 Lisp_Object Vsound_alist; | 57 Lisp_Object Vsound_alist; |
56 Lisp_Object Vsynchronous_sounds; | 58 Lisp_Object Vsynchronous_sounds; |
57 Lisp_Object Vnative_sound_only_on_console; | 59 Lisp_Object Vnative_sound_only_on_console; |
58 Lisp_Object Q_volume, Q_pitch, Q_duration, Q_sound; | 60 Lisp_Object Q_volume, Q_pitch, Q_duration, Q_sound; |
59 | 61 Lisp_Object Qsound_error; |
60 | 62 |
61 #ifdef HAVE_NAS_SOUND | 63 |
62 extern int nas_play_sound_file (char *name, int volume); | 64 #ifdef HAVE_NAS_SOUND |
63 extern int nas_play_sound_data (unsigned char *data, int length, int volume); | 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); | |
64 extern int nas_wait_for_sounds (void); | 67 extern int nas_wait_for_sounds (void); |
65 extern char *nas_init_play (Display *); | 68 extern Extbyte *nas_init_play (Display *); |
66 | 69 #endif |
67 Lisp_Object Qnas; | 70 |
68 #endif | 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 } | |
69 | 76 |
70 DEFUN ("play-sound-file", Fplay_sound_file, 1, 3, "fSound file name: ", /* | 77 DEFUN ("play-sound-file", Fplay_sound_file, 1, 3, "fSound file name: ", /* |
71 Play the named sound file on DEVICE's speaker at the specified volume | 78 Play the named sound file on DEVICE's speaker at the specified volume |
72 \(0-100, default specified by the `bell-volume' variable). | 79 \(0-100, default specified by the `bell-volume' variable). |
73 On Unix machines the sound file must be in the Sun/NeXT U-LAW format | 80 On Unix machines the sound file must be in the Sun/NeXT U-LAW format |
105 /* #### This is crockish. It might be a better idea to try | 112 /* #### This is crockish. It might be a better idea to try |
106 to open the file, and use report_file_error() if it | 113 to open the file, and use report_file_error() if it |
107 fails. --hniksic */ | 114 fails. --hniksic */ |
108 if (NILP (Ffile_exists_p (file))) | 115 if (NILP (Ffile_exists_p (file))) |
109 file = | 116 file = |
110 signal_simple_continuable_error ("File does not exist", file); | 117 signal_continuable_error (Qfile_error, |
118 "File does not exist", file); | |
111 else | 119 else |
112 file = | 120 file = |
113 signal_simple_continuable_error ("File is unreadable", file); | 121 signal_continuable_error (Qfile_error, |
122 "File is unreadable", file); | |
114 } | 123 } |
115 } | 124 } |
116 UNGCPRO; | 125 UNGCPRO; |
117 | 126 |
118 #ifdef HAVE_NAS_SOUND | 127 #ifdef HAVE_NAS_SOUND |
119 if (DEVICE_CONNECTED_TO_NAS_P (d)) | 128 if (DEVICE_CONNECTED_TO_NAS_P (d)) |
120 { | 129 { |
121 char *fileext; | 130 Extbyte *fileext; |
122 | 131 |
123 LISP_STRING_TO_EXTERNAL (file, fileext, Qfile_name); | 132 LISP_STRING_TO_EXTERNAL (file, fileext, Qfile_name); |
124 /* #### NAS code should allow specification of a device. */ | 133 /* #### NAS code should allow specification of a device. */ |
125 if (nas_play_sound_file (fileext, vol)) | 134 if (nas_play_sound_file (fileext, vol)) |
126 return Qnil; | 135 return Qnil; |
128 #endif /* HAVE_NAS_SOUND */ | 137 #endif /* HAVE_NAS_SOUND */ |
129 | 138 |
130 #ifdef HAVE_ESD_SOUND | 139 #ifdef HAVE_ESD_SOUND |
131 if (DEVICE_CONNECTED_TO_ESD_P (d)) | 140 if (DEVICE_CONNECTED_TO_ESD_P (d)) |
132 { | 141 { |
133 char *fileext; | 142 Extbyte *fileext; |
134 int result; | 143 int result; |
135 | 144 |
136 LISP_STRING_TO_EXTERNAL (file, fileext, Qfile_name); | 145 LISP_STRING_TO_EXTERNAL (file, fileext, Qfile_name); |
137 | 146 |
138 /* #### ESD uses alarm(). But why should we also stop SIGIO? */ | 147 /* #### ESD uses alarm(). But why should we also stop SIGIO? */ |
145 #endif /* HAVE_ESD_SOUND */ | 154 #endif /* HAVE_ESD_SOUND */ |
146 | 155 |
147 #ifdef HAVE_NATIVE_SOUND | 156 #ifdef HAVE_NATIVE_SOUND |
148 if (NILP (Vnative_sound_only_on_console) || DEVICE_ON_CONSOLE_P (d)) | 157 if (NILP (Vnative_sound_only_on_console) || DEVICE_ON_CONSOLE_P (d)) |
149 { | 158 { |
150 const char *fileext; | 159 Extbyte *fileext; |
151 | 160 |
152 LISP_STRING_TO_EXTERNAL (file, fileext, Qfile_name); | 161 LISP_STRING_TO_EXTERNAL (file, fileext, Qfile_name); |
153 /* The sound code doesn't like getting SIGIO interrupts. | 162 /* The sound code doesn't like getting SIGIO interrupts. |
154 Unix sucks! */ | 163 Unix sucks! */ |
155 stop_interrupts (); | 164 stop_interrupts (); |
156 play_sound_file ((char *) fileext, vol); | 165 play_sound_file (fileext, vol); |
157 start_interrupts (); | 166 start_interrupts (); |
158 QUIT; | 167 QUIT; |
159 } | 168 } |
160 #endif /* HAVE_NATIVE_SOUND */ | 169 #endif /* HAVE_NATIVE_SOUND */ |
161 | 170 |
309 Else just beep. | 318 Else just beep. |
310 */ | 319 */ |
311 #ifdef HAVE_NAS_SOUND | 320 #ifdef HAVE_NAS_SOUND |
312 if (DEVICE_CONNECTED_TO_NAS_P (d) && STRINGP (sound)) | 321 if (DEVICE_CONNECTED_TO_NAS_P (d) && STRINGP (sound)) |
313 { | 322 { |
314 const Extbyte *soundext; | 323 const UChar_Binary *soundext; |
315 Extcount soundextlen; | 324 Extcount soundextlen; |
316 | 325 |
317 TO_EXTERNAL_FORMAT (LISP_STRING, sound, | 326 TO_EXTERNAL_FORMAT (LISP_STRING, sound, |
318 ALLOCA, (soundext, soundextlen), | 327 ALLOCA, (soundext, soundextlen), |
319 Qbinary); | 328 Qbinary); |
320 if (nas_play_sound_data ((unsigned char*)soundext, soundextlen, vol)) | 329 if (nas_play_sound_data (soundext, soundextlen, vol)) |
321 return Qnil; | 330 return Qnil; |
322 } | 331 } |
323 #endif /* HAVE_NAS_SOUND */ | 332 #endif /* HAVE_NAS_SOUND */ |
324 | 333 |
325 #ifdef HAVE_ESD_SOUND | 334 #ifdef HAVE_ESD_SOUND |
326 if (DEVICE_CONNECTED_TO_ESD_P (d) && STRINGP (sound)) | 335 if (DEVICE_CONNECTED_TO_ESD_P (d) && STRINGP (sound)) |
327 { | 336 { |
328 Extbyte *soundext; | 337 UChar_Binary *soundext; |
329 Extcount soundextlen; | 338 Extcount soundextlen; |
330 int succes; | 339 int succes; |
331 | 340 |
332 TO_EXTERNAL_FORMAT (LISP_STRING, sound, ALLOCA, (soundext, soundextlen), | 341 TO_EXTERNAL_FORMAT (LISP_STRING, sound, ALLOCA, (soundext, soundextlen), |
333 Qbinary); | 342 Qbinary); |
334 | 343 |
335 /* #### ESD uses alarm(). But why should we also stop SIGIO? */ | 344 /* #### ESD uses alarm(). But why should we also stop SIGIO? */ |
336 stop_interrupts (); | 345 stop_interrupts (); |
337 succes = esd_play_sound_data ((unsigned char *) soundext, soundextlen, vol); | 346 succes = esd_play_sound_data (soundext, soundextlen, vol); |
338 start_interrupts (); | 347 start_interrupts (); |
339 QUIT; | 348 QUIT; |
340 if(succes) | 349 if(succes) |
341 return Qnil; | 350 return Qnil; |
342 } | 351 } |
344 | 353 |
345 #ifdef HAVE_NATIVE_SOUND | 354 #ifdef HAVE_NATIVE_SOUND |
346 if ((NILP (Vnative_sound_only_on_console) || DEVICE_ON_CONSOLE_P (d)) | 355 if ((NILP (Vnative_sound_only_on_console) || DEVICE_ON_CONSOLE_P (d)) |
347 && STRINGP (sound)) | 356 && STRINGP (sound)) |
348 { | 357 { |
349 const Extbyte *soundext; | 358 UChar_Binary *soundext; |
350 Extcount soundextlen; | 359 Extcount soundextlen; |
351 int succes; | 360 int succes; |
352 | 361 |
353 TO_EXTERNAL_FORMAT (LISP_STRING, sound, | 362 TO_EXTERNAL_FORMAT (LISP_STRING, sound, |
354 ALLOCA, (soundext, soundextlen), | 363 ALLOCA, (soundext, soundextlen), |
355 Qbinary); | 364 Qbinary); |
356 /* The sound code doesn't like getting SIGIO interrupts. Unix sucks! */ | 365 /* The sound code doesn't like getting SIGIO interrupts. Unix sucks! */ |
357 stop_interrupts (); | 366 stop_interrupts (); |
358 succes = play_sound_data ((unsigned char*)soundext, soundextlen, vol); | 367 succes = play_sound_data (soundext, soundextlen, vol); |
359 start_interrupts (); | 368 start_interrupts (); |
360 QUIT; | 369 QUIT; |
361 if (succes) | 370 if (succes) |
362 return Qnil; | 371 return Qnil; |
363 } | 372 } |
401 XSETDEVICE (device, d); | 410 XSETDEVICE (device, d); |
402 now = time (0); | 411 now = time (0); |
403 | 412 |
404 if (NILP (arg) && !NILP (Vexecuting_macro)) | 413 if (NILP (arg) && !NILP (Vexecuting_macro)) |
405 /* Stop executing a keyboard macro. */ | 414 /* Stop executing a keyboard macro. */ |
406 error ("Keyboard macro terminated by a command ringing the bell"); | 415 invalid_operation ("Keyboard macro terminated by a command ringing the bell", Qunbound); |
407 | 416 |
408 if (d == last_bell_device && now-last_bell_time < bell_inhibit_time) | 417 if (d == last_bell_device && now-last_bell_time < bell_inhibit_time) |
409 return Qnil; | 418 return Qnil; |
410 else if (!NILP (Vvisible_bell) && DEVMETH (d, flash, (d))) | 419 else if (!NILP (Vvisible_bell) && DEVMETH (d, flash, (d))) |
411 ; | 420 ; |
451 init_nas_sound (struct device *d) | 460 init_nas_sound (struct device *d) |
452 { | 461 { |
453 #ifdef HAVE_X_WINDOWS | 462 #ifdef HAVE_X_WINDOWS |
454 if (DEVICE_X_P (d)) | 463 if (DEVICE_X_P (d)) |
455 { | 464 { |
456 char *err_message = nas_init_play (DEVICE_X_DISPLAY (d)); | 465 Extbyte *err_message = nas_init_play (DEVICE_X_DISPLAY (d)); |
457 DEVICE_CONNECTED_TO_NAS_P (d) = !err_message; | 466 DEVICE_CONNECTED_TO_NAS_P (d) = !err_message; |
458 /* Print out the message? */ | 467 /* Print out the message? */ |
459 } | 468 } |
460 #endif /* HAVE_X_WINDOWS */ | 469 #endif /* HAVE_X_WINDOWS */ |
461 } | 470 } |
477 that $DISPLAY points to, and $DISPLAY points to frame 0 of that | 486 that $DISPLAY points to, and $DISPLAY points to frame 0 of that |
478 machine. | 487 machine. |
479 */ | 488 */ |
480 | 489 |
481 Display *display = DEVICE_X_DISPLAY (d); | 490 Display *display = DEVICE_X_DISPLAY (d); |
482 char *dpy = DisplayString (display); | 491 Extbyte *dpy = DisplayString (display); |
483 char *tail = (char *) strchr (dpy, ':'); | 492 Extbyte *tail = strchr (dpy, ':'); |
484 if (! tail || | 493 if (! tail || |
485 strncmp (tail, ":0", 2)) | 494 strncmp (tail, ":0", 2)) |
486 DEVICE_ON_CONSOLE_P (d) = 0; | 495 DEVICE_ON_CONSOLE_P (d) = 0; |
487 else | 496 else |
488 { | 497 { |
489 char dpyname[255], localname[255]; | 498 Extbyte dpyname[255], localname[255]; |
490 | 499 |
491 /* some systems can't handle SIGIO or SIGALARM in gethostbyname. */ | 500 /* some systems can't handle SIGIO or SIGALARM in gethostbyname. */ |
492 stop_interrupts (); | 501 stop_interrupts (); |
493 strncpy (dpyname, dpy, tail-dpy); | 502 strncpy (dpyname, dpy, tail-dpy); |
494 dpyname [tail-dpy] = 0; | 503 dpyname [tail-dpy] = 0; |
515 struct hostent *h = gethostbyname (dpyname); | 524 struct hostent *h = gethostbyname (dpyname); |
516 if (!h) | 525 if (!h) |
517 DEVICE_ON_CONSOLE_P (d) = 0; | 526 DEVICE_ON_CONSOLE_P (d) = 0; |
518 else | 527 else |
519 { | 528 { |
520 char hn [255]; | 529 Extbyte hn [255]; |
521 struct hostent *l; | 530 struct hostent *l; |
522 strcpy (hn, h->h_name); | 531 strcpy (hn, h->h_name); |
523 l = gethostbyname (localname); | 532 l = gethostbyname (localname); |
524 DEVICE_ON_CONSOLE_P (d) = (l && !(strcmp (l->h_name, hn))); | 533 DEVICE_ON_CONSOLE_P (d) = (l && !(strcmp (l->h_name, hn))); |
525 } | 534 } |
545 } | 554 } |
546 | 555 |
547 void | 556 void |
548 syms_of_sound (void) | 557 syms_of_sound (void) |
549 { | 558 { |
550 defkeyword (&Q_volume, ":volume"); | 559 DEFKEYWORD (Q_volume); |
551 defkeyword (&Q_pitch, ":pitch"); | 560 DEFKEYWORD (Q_pitch); |
552 defkeyword (&Q_duration, ":duration"); | 561 DEFKEYWORD (Q_duration); |
553 defkeyword (&Q_sound, ":sound"); | 562 DEFKEYWORD (Q_sound); |
554 | 563 |
555 #ifdef HAVE_NAS_SOUND | 564 DEFERROR_STANDARD (Qsound_error, Qio_error); |
556 defsymbol (&Qnas, "nas"); | |
557 #endif | |
558 | 565 |
559 DEFSUBR (Fplay_sound_file); | 566 DEFSUBR (Fplay_sound_file); |
560 DEFSUBR (Fplay_sound); | 567 DEFSUBR (Fplay_sound); |
561 DEFSUBR (Fding); | 568 DEFSUBR (Fding); |
562 DEFSUBR (Fwait_for_sounds); | 569 DEFSUBR (Fwait_for_sounds); |