comparison src/sound.c @ 406:b8cc9ab3f761 r21-2-33

Import from CVS: tag r21-2-33
author cvs
date Mon, 13 Aug 2007 11:17:09 +0200
parents 2f8bb876ab1d
children de805c49cfc1
comparison
equal deleted inserted replaced
405:0e08f63c74d2 406:b8cc9ab3f761
41 #include <unistd.h> 41 #include <unistd.h>
42 #endif 42 #endif
43 43
44 #ifdef HAVE_NATIVE_SOUND 44 #ifdef HAVE_NATIVE_SOUND
45 # include <netdb.h> 45 # include <netdb.h>
46 # include "nativesound.h"
46 #endif 47 #endif
47 48
48 #ifdef HAVE_ESD_SOUND 49 #ifdef HAVE_ESD_SOUND
49 extern int esd_play_sound_file (char *file, int vol); 50 extern int esd_play_sound_file (char *file, int vol);
50 extern int esd_play_sound_data (unsigned char *data, size_t length, int vol); 51 extern int esd_play_sound_data (unsigned char *data, size_t length, int vol);
56 Lisp_Object Vsound_alist; 57 Lisp_Object Vsound_alist;
57 Lisp_Object Vsynchronous_sounds; 58 Lisp_Object Vsynchronous_sounds;
58 Lisp_Object Vnative_sound_only_on_console; 59 Lisp_Object Vnative_sound_only_on_console;
59 Lisp_Object Q_volume, Q_pitch, Q_duration, Q_sound; 60 Lisp_Object Q_volume, Q_pitch, Q_duration, Q_sound;
60 61
61 /* These are defined in the appropriate file (sunplay.c, sgiplay.c,
62 or hpplay.c). */
63
64 extern void play_sound_file (char *name, int volume);
65 extern void play_sound_data (unsigned char *data, int length, int volume);
66 62
67 #ifdef HAVE_NAS_SOUND 63 #ifdef HAVE_NAS_SOUND
68 extern int nas_play_sound_file (char *name, int volume); 64 extern int nas_play_sound_file (char *name, int volume);
69 extern int nas_play_sound_data (unsigned char *data, int length, int volume); 65 extern int nas_play_sound_data (unsigned char *data, int length, int volume);
70 extern int nas_wait_for_sounds (void); 66 extern int nas_wait_for_sounds (void);
137 133
138 #ifdef HAVE_ESD_SOUND 134 #ifdef HAVE_ESD_SOUND
139 if (DEVICE_CONNECTED_TO_ESD_P (d)) 135 if (DEVICE_CONNECTED_TO_ESD_P (d))
140 { 136 {
141 char *fileext; 137 char *fileext;
138 int result;
142 139
143 TO_EXTERNAL_FORMAT (LISP_STRING, file, 140 TO_EXTERNAL_FORMAT (LISP_STRING, file,
144 C_STRING_ALLOCA, fileext, 141 C_STRING_ALLOCA, fileext,
145 Qfile_name); 142 Qfile_name);
146 if (esd_play_sound_file (fileext, vol)) 143
144 /* #### ESD uses alarm(). But why should we also stop SIGIO? */
145 stop_interrupts ();
146 result = esd_play_sound_file (fileext, vol);
147 start_interrupts ();
148 if (result)
147 return Qnil; 149 return Qnil;
148 } 150 }
149 #endif /* HAVE_ESD_SOUND */ 151 #endif /* HAVE_ESD_SOUND */
150 152
151 #ifdef HAVE_NATIVE_SOUND 153 #ifdef HAVE_NATIVE_SOUND
275 { 277 {
276 int looking_for_default = 0; 278 int looking_for_default = 0;
277 /* variable `sound' is anything that can be a cdr in sound-alist */ 279 /* variable `sound' is anything that can be a cdr in sound-alist */
278 Lisp_Object new_volume, pitch, duration, data; 280 Lisp_Object new_volume, pitch, duration, data;
279 int loop_count = 0; 281 int loop_count = 0;
280 int vol, pit, dur; 282 int vol, pit, dur, succes;
281 struct device *d = decode_device (device); 283 struct device *d = decode_device (device);
282 284
283 /* NOTE! You'd better not signal an error in here. */ 285 /* NOTE! You'd better not signal an error in here. */
284 286
285 287
334 Extbyte *soundext; 336 Extbyte *soundext;
335 Extcount soundextlen; 337 Extcount soundextlen;
336 338
337 TO_EXTERNAL_FORMAT (LISP_STRING, sound, ALLOCA, (soundext, soundextlen), 339 TO_EXTERNAL_FORMAT (LISP_STRING, sound, ALLOCA, (soundext, soundextlen),
338 Qbinary); 340 Qbinary);
339 if (esd_play_sound_data (soundext, soundextlen, vol)) 341
340 return Qnil; 342 /* #### ESD uses alarm(). But why should we also stop SIGIO? */
343 stop_interrupts ();
344 succes = esd_play_sound_data (soundext, soundextlen, vol);
345 start_interrupts ();
346 QUIT;
347 if(succes)
348 return Qnil;
341 } 349 }
342 #endif /* HAVE_ESD_SOUND */ 350 #endif /* HAVE_ESD_SOUND */
343 351
344 #ifdef HAVE_NATIVE_SOUND 352 #ifdef HAVE_NATIVE_SOUND
345 if ((NILP (Vnative_sound_only_on_console) || DEVICE_ON_CONSOLE_P (d)) 353 if ((NILP (Vnative_sound_only_on_console) || DEVICE_ON_CONSOLE_P (d))
351 TO_EXTERNAL_FORMAT (LISP_STRING, sound, 359 TO_EXTERNAL_FORMAT (LISP_STRING, sound,
352 ALLOCA, (soundext, soundextlen), 360 ALLOCA, (soundext, soundextlen),
353 Qbinary); 361 Qbinary);
354 /* The sound code doesn't like getting SIGIO interrupts. Unix sucks! */ 362 /* The sound code doesn't like getting SIGIO interrupts. Unix sucks! */
355 stop_interrupts (); 363 stop_interrupts ();
356 play_sound_data ((unsigned char*)soundext, soundextlen, vol); 364 succes = play_sound_data ((unsigned char*)soundext, soundextlen, vol);
357 start_interrupts (); 365 start_interrupts ();
358 QUIT; 366 QUIT;
359 return Qnil; 367 if (succes)
368 return Qnil;
360 } 369 }
361 #endif /* HAVE_NATIVE_SOUND */ 370 #endif /* HAVE_NATIVE_SOUND */
362 371
363 DEVMETH (d, ring_bell, (d, vol, pit, dur)); 372 DEVMETH (d, ring_bell, (d, vol, pit, dur));
364 return Qnil; 373 return Qnil;