comparison src/sgiplay.c @ 609:13e3d7ae7155

[xemacs-hg @ 2001-06-06 12:34:42 by ben] nitpicky fixes: emodules.c, tooltalk.c, process-unix.c: Fix warnings pointed out by Martin. lisp.h: Correct usage of CBufbyte. esd.c: indentation changes. bytecode.c, eval.c, fileio.c: Use CBufbyte instead of char for error/warning functions. linuxplay.c, miscplay.c, sgiplay.c, sunplay.c: Define DONT_ENCAPSULATE. (All encapsulation is removed in my pending Mule workspace.) sgiplay.c: Put back #include <audio.h> accidentally removed. Make play_sound_data return an int, like all other such functions in *play.c. sound.c: Fix up documentation of `play-sound'. sysfile.h: Don't include sys/fcntl.h, as per Martin's advice.
author ben
date Wed, 06 Jun 2001 12:34:47 +0000
parents 183866b06e0b
children 943eaba38521
comparison
equal deleted inserted replaced
608:4d7fdf497470 609:13e3d7ae7155
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. */ 24 /* This file Mule-ized by Ben Wing, 5-15-01. */
25 25
26 #define DONT_ENCAPSULATE
27
26 #include <config.h> 28 #include <config.h>
27 #include "lisp.h" 29 #include "lisp.h"
28 30
29 #include "sound.h" 31 #include "sound.h"
30 32
31 #include "sysfile.h" 33 #include "sysfile.h"
32 #include "sysproc.h" /* netinet/in.h for ntohl() etc. */ 34 #include "sysproc.h" /* netinet/in.h for ntohl() etc. */
35
36 #include <audio.h>
33 37
34 /* Configuration options */ 38 /* Configuration options */
35 39
36 /* ability to parse Sun/NeXT (.au or .snd) audio file headers. The 40 /* ability to parse Sun/NeXT (.au or .snd) audio file headers. The
37 .snd format supports all sampling rates and sample widths that are 41 .snd format supports all sampling rates and sample widths that are
171 175
172 /* Forward declarations */ 176 /* Forward declarations */
173 177
174 static Lisp_Object close_sound_file (Lisp_Object); 178 static Lisp_Object close_sound_file (Lisp_Object);
175 static AudioContext audio_initialize (UChar_Binary *, int, int); 179 static AudioContext audio_initialize (UChar_Binary *, int, int);
176 static void play_internal (UChar_Binary *, int, AudioContext); 180 static int play_internal (UChar_Binary *, int, AudioContext);
177 static void drain_audio_port (AudioContext); 181 static void drain_audio_port (AudioContext);
178 static void write_mulaw_8_chunk (void *, void *, AudioContext); 182 static void write_mulaw_8_chunk (void *, void *, AudioContext);
179 static void write_linear_chunk (void *, void *, AudioContext); 183 static void write_linear_chunk (void *, void *, AudioContext);
180 static void write_linear_32_chunk (void *, void *, AudioContext); 184 static void write_linear_32_chunk (void *, void *, AudioContext);
181 static Lisp_Object restore_audio_port (Lisp_Object); 185 static Lisp_Object restore_audio_port (Lisp_Object);
251 saved_device_state[5] = XINT (contents[2]); 255 saved_device_state[5] = XINT (contents[2]);
252 ALsetparams (AL_DEFAULT_DEVICE, saved_device_state, 6); 256 ALsetparams (AL_DEFAULT_DEVICE, saved_device_state, 6);
253 return Qnil; 257 return Qnil;
254 } 258 }
255 259
256 void 260 int
257 play_sound_data (UChar_Binary *data, int length, int volume) 261 play_sound_data (UChar_Binary *data, int length, int volume)
258 { 262 {
259 int count = specpdl_depth (); 263 int count = specpdl_depth ();
260 AudioContext ac; 264 AudioContext ac;
265 int result;
261 266
262 ac = audio_initialize (data, length, volume); 267 ac = audio_initialize (data, length, volume);
263 if (ac == (AudioContext) 0) 268 if (ac == (AudioContext) 0)
264 return; 269 return 0;
265 play_internal (data, length, ac); 270 result = play_internal (data, length, ac);
266 drain_audio_port (ac); 271 drain_audio_port (ac);
267 unbind_to (count, Qnil); 272 unbind_to (count, Qnil);
273 return result;
268 } 274 }
269 275
270 static AudioContext 276 static AudioContext
271 audio_initialize (UChar_Binary *data, int length, int volume) 277 audio_initialize (UChar_Binary *data, int length, int volume)
272 { 278 {
309 ac = initialize_audio_port (& desc); 315 ac = initialize_audio_port (& desc);
310 desc = * ac; 316 desc = * ac;
311 return ac; 317 return ac;
312 } 318 }
313 319
314 static void 320 static int
315 play_internal (UChar_Binary *data, int length, AudioContext ac) 321 play_internal (UChar_Binary *data, int length, AudioContext ac)
316 { 322 {
317 UChar_Binary * limit; 323 UChar_Binary * limit;
318 if (ac == (AudioContext) 0) 324 if (ac == (AudioContext) 0)
319 return; 325 return 0;
320 326
321 data = (UChar_Binary *) ac->ac_data; 327 data = (UChar_Binary *) ac->ac_data;
322 limit = data + ac->ac_size; 328 limit = data + ac->ac_size;
323 while (data < limit) 329 while (data < limit)
324 { 330 {
330 QUIT; 336 QUIT;
331 337
332 (* ac->ac_write_chunk_function) (data, chunklimit, ac); 338 (* ac->ac_write_chunk_function) (data, chunklimit, ac);
333 data = chunklimit; 339 data = chunklimit;
334 } 340 }
341
342 return 1;
335 } 343 }
336 344
337 static void 345 static void
338 drain_audio_port (AudioContext ac) 346 drain_audio_port (AudioContext ac)
339 { 347 {