Mercurial > hg > xemacs-beta
comparison src/hpplay.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 | 6db80f4ab17c |
comparison
equal
deleted
inserted
replaced
562:c775bd016b32 | 563:183866b06e0b |
---|---|
16 along with XEmacs; see the file COPYING. If not, write to | 16 along with XEmacs; see the file COPYING. If not, write to |
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
18 Boston, MA 02111-1307, USA. */ | 18 Boston, MA 02111-1307, USA. */ |
19 | 19 |
20 /* Synched up with: Not in FSF. */ | 20 /* Synched up with: Not in FSF. */ |
21 | |
22 /* This file Mule-ized by Ben Wing, 5-15-01. */ | |
21 | 23 |
22 | 24 |
23 /*** | 25 /*** |
24 NAME | 26 NAME |
25 hpplay | 27 hpplay |
49 */ | 51 */ |
50 | 52 |
51 #include <config.h> | 53 #include <config.h> |
52 #include "lisp.h" | 54 #include "lisp.h" |
53 | 55 |
54 #include "nativesound.h" | 56 #include "sound.h" |
55 | 57 |
56 #include <stdlib.h> | |
57 #include <stdio.h> | |
58 #ifdef HPUX10 | 58 #ifdef HPUX10 |
59 #include <Alib.h> | 59 #include <Alib.h> |
60 #include <CUlib.h> | 60 #include <CUlib.h> |
61 #else /* !HPUX 10 */ | 61 #else /* !HPUX 10 */ |
62 #include <audio/Alib.h> | 62 #include <audio/Alib.h> |
69 Fixnum hp_play_gain; | 69 Fixnum hp_play_gain; |
70 | 70 |
71 /* Functions */ | 71 /* Functions */ |
72 | 72 |
73 /* error handling */ | 73 /* error handling */ |
74 void player_error_internal( | 74 void |
75 Audio * audio, | 75 player_error_internal (Audio * audio, Char_ASCII * text, long errorCode) |
76 char * text, | 76 { |
77 long errorCode | 77 Extbyte errorbuff[132]; |
78 ) | 78 Bufbyte *interr; |
79 { | 79 |
80 char errorbuff[132],buf[256]; | 80 AGetErrorText (audio, errorCode, errorbuff, 131); |
81 | 81 EXTERNAL_TO_C_STRING (errorbuf, interr, Qnative); |
82 AGetErrorText(audio, errorCode, errorbuff, 131); | 82 |
83 sprintf(buf,"%s: %s\n",text,errorbuff); | 83 signal_error (Qsound_error, text, build_string (interr)); |
84 error(buf); | 84 } |
85 } | 85 |
86 | 86 long |
87 long myHandler(audio, err_event) | 87 myHandler( Audio * audio, AErrorEvent * err_event) |
88 Audio * audio; | |
89 AErrorEvent * err_event; | |
90 { | 88 { |
91 player_error_internal(audio, "Internal sound error", err_event->error_code); | 89 player_error_internal(audio, "Internal sound error", err_event->error_code); |
92 return 1; /* Must return something, was orig. an exit */ | 90 return 1; /* Must return something, was orig. an exit */ |
93 } | 91 } |
94 | 92 |
95 /* Playing */ | 93 /* Playing */ |
96 void | 94 void |
97 play_bucket_internal(audio, pSBucket, volume) | 95 play_bucket_internal( Audio *audio, SBucket *pSBucket, long volume) |
98 Audio *audio; | 96 { |
99 SBucket *pSBucket; | 97 SBPlayParams playParams; |
100 long volume; | 98 AGainEntry gainEntry; |
101 { | 99 ATransID xid; |
102 SBPlayParams playParams; | 100 long status; |
103 AGainEntry gainEntry; | 101 |
104 ATransID xid; | 102 playParams.priority = APriorityNormal; /* normal priority */ |
105 long status; | 103 |
106 char * speaker; | 104 /* |
107 | 105 * We can't signal an error, because all h*ll would break loose if |
108 playParams.priority = APriorityNormal; /* normal priority */ | 106 * we did. |
109 | 107 */ |
110 /* | 108 if (EQ (Vhp_play_speaker, Qexternal)) |
111 * We can't signal an error, because all h*ll would break loose if | 109 gainEntry.u.o.out_dst = AODTMonoJack; |
112 * we did. | 110 else |
113 */ | 111 gainEntry.u.o.out_dst = AODTMonoIntSpeaker; |
114 if (SYMBOLP (Vhp_play_speaker)) | 112 |
113 gainEntry.u.o.out_ch = AOCTMono; | |
114 gainEntry.gain = AUnityGain; | |
115 playParams.gain_matrix.type = AGMTOutput; /* gain matrix */ | |
116 playParams.gain_matrix.num_entries = 1; | |
117 playParams.gain_matrix.gain_entries = &gainEntry; | |
118 playParams.play_volume = hp_play_gain; /* play volume */ | |
119 playParams.pause_first = False; /* don't pause */ | |
120 playParams.start_offset.type = ATTSamples; /* start offset 0 */ | |
121 playParams.start_offset.u.samples = 0; | |
122 playParams.duration.type = ATTFullLength; /* play entire sample */ | |
123 playParams.loop_count = 1; /* play sample just once */ | |
124 playParams.previous_transaction = 0; /* no linked transaction */ | |
125 playParams.event_mask = 0; /* don't solicit any events */ | |
126 | |
127 /* | |
128 * play the sound bucket | |
129 */ | |
130 xid = APlaySBucket( audio, pSBucket, &playParams, NULL ); | |
131 | |
132 /* | |
133 * set close mode to prevent playback from stopping | |
134 * when we close audio connection | |
135 */ | |
136 ASetCloseDownMode( audio, AKeepTransactions, &status ); | |
137 | |
138 /* | |
139 * That's all, folks! | |
140 * Always destroy bucket and close connection. | |
141 */ | |
142 ADestroySBucket( audio, pSBucket, &status ); | |
143 ACloseAudio( audio, &status ); | |
144 } | |
145 | |
146 void | |
147 play_sound_file (Extbyte * sound_file, int volume) | |
148 { | |
149 sbucket *pSBucket; | |
150 Audio *audio; | |
151 long status; | |
152 AErrorHandler prevHandler; /* pointer to previous handler */ | |
153 Extbyte *server; | |
154 | |
155 if (STRINGP (Vhp_play_server)) | |
156 LISP_STRING_TO_EXTERNAL (Vhp_play_server, server, Qnative); | |
157 else | |
158 server = ""; | |
159 | |
160 /* | |
161 * open audio connection | |
162 */ | |
163 audio = AOpenAudio( server, &status ); | |
164 if( status ) | |
115 { | 165 { |
116 speaker = (char *) (string_data (XSYMBOL (Vhp_play_speaker)->name)); | 166 player_error_internal( audio, "Open audio failed", status ); |
117 | |
118 /* | |
119 * setup the playback parameters | |
120 */ | |
121 | |
122 /* speaker selection */ | |
123 if ( strcmp(speaker,"external") == 0 ) { | |
124 gainEntry.u.o.out_dst = AODTMonoJack; | |
125 } else { | |
126 gainEntry.u.o.out_dst = AODTMonoIntSpeaker; | |
127 } | |
128 } | 167 } |
129 else | 168 |
130 { | 169 /* replace default error handler */ |
131 /* | 170 prevHandler = ASetErrorHandler(myHandler); |
132 * Quietly revert to the internal speaker | 171 |
133 */ | 172 /* |
134 gainEntry.u.o.out_dst = AODTMonoIntSpeaker; | 173 * Load the audio file into a sound bucket |
135 } | 174 */ |
136 | 175 |
137 gainEntry.u.o.out_ch = AOCTMono; | 176 pSBucket = ALoadAFile( audio, sound_file, AFFUnknown, 0, NULL, NULL ); |
138 gainEntry.gain = AUnityGain; | 177 |
139 playParams.gain_matrix.type = AGMTOutput; /* gain matrix */ | 178 /* |
140 playParams.gain_matrix.num_entries = 1; | 179 * Play the bucket |
141 playParams.gain_matrix.gain_entries = &gainEntry; | 180 */ |
142 playParams.play_volume = hp_play_gain; /* play volume */ | 181 |
143 playParams.pause_first = False; /* don't pause */ | 182 play_bucket_internal(audio, pSBucket, volume); |
144 playParams.start_offset.type = ATTSamples; /* start offset 0 */ | 183 |
145 playParams.start_offset.u.samples = 0; | 184 ASetErrorHandler(prevHandler); |
146 playParams.duration.type = ATTFullLength; /* play entire sample */ | |
147 playParams.loop_count = 1; /* play sample just once */ | |
148 playParams.previous_transaction = 0; /* no linked transaction */ | |
149 playParams.event_mask = 0; /* don't solicit any events */ | |
150 | |
151 /* | |
152 * play the sound bucket | |
153 */ | |
154 xid = APlaySBucket( audio, pSBucket, &playParams, NULL ); | |
155 | |
156 /* | |
157 * set close mode to prevent playback from stopping | |
158 * when we close audio connection | |
159 */ | |
160 ASetCloseDownMode( audio, AKeepTransactions, &status ); | |
161 | |
162 /* | |
163 * That's all, folks! | |
164 * Always destroy bucket and close connection. | |
165 */ | |
166 ADestroySBucket( audio, pSBucket, &status ); | |
167 ACloseAudio( audio, &status ); | |
168 } | |
169 | |
170 void | |
171 play_sound_file (sound_file, volume) | |
172 char * sound_file; | |
173 int volume; | |
174 { | |
175 SBucket *pSBucket; | |
176 Audio *audio; | |
177 long status; | |
178 AErrorHandler prevHandler; /* pointer to previous handler */ | |
179 char *server; | |
180 | |
181 if (STRINGP(Vhp_play_server)) | |
182 server = (char *) XSTRING_DATA (Vhp_play_server); | |
183 server = ""; | |
184 | |
185 /* | |
186 * open audio connection | |
187 */ | |
188 audio = AOpenAudio( server, &status ); | |
189 if( status ) { | |
190 player_error_internal( audio, "Open audio failed", status ); | |
191 } | |
192 | |
193 /* replace default error handler */ | |
194 prevHandler = ASetErrorHandler(myHandler); | |
195 | |
196 /* | |
197 * Load the audio file into a sound bucket | |
198 */ | |
199 | |
200 pSBucket = ALoadAFile( audio, sound_file, AFFUnknown, 0, NULL, NULL ); | |
201 | |
202 /* | |
203 * Play the bucket | |
204 */ | |
205 | |
206 play_bucket_internal(audio, pSBucket, volume); | |
207 | |
208 ASetErrorHandler(prevHandler); | |
209 } | 185 } |
210 | 186 |
211 | 187 |
212 int | 188 int |
213 play_sound_data (data, length, volume) | 189 play_sound_data (UChar_Binary * data, int length, int volume) |
214 unsigned char * data; | 190 { |
215 int length; | 191 SBucket *pSBucket; |
216 int volume; | 192 Audio *audio; |
217 { | 193 AErrorHandler prevHandler; |
218 SBucket *pSBucket; | 194 SunHeader *header; |
219 Audio *audio; | 195 long status; |
220 AErrorHandler prevHandler; | 196 Extbyte *server; |
221 SunHeader *header; | 197 int result; |
222 long status; | 198 |
223 char *server; | 199 /* #### Finish this to return an error code. |
224 int result; | 200 This function signal a lisp error. How consistent with the rest. |
225 | 201 What if this function is needed in doing the beep for the error? |
226 /* #### Finish this to return an error code. | 202 |
227 This function signal a lisp error. How consistent with the rest. | 203 Apparently the author of this didn't read the comment in |
228 What if this function is needed in doing the beep for the error? | 204 Fplay_sound. |
229 | 205 */ |
230 Apparently the author of this didn't read the comment in | |
231 Fplay_sound. | |
232 */ | |
233 | 206 |
234 | 207 |
235 if (STRINGP (Vhp_play_server)) | 208 if (STRINGP (Vhp_play_server)) |
236 server = (char *) XSTRING_DATA (Vhp_play_server); | 209 LISP_STRING_TO_EXTERNAL (Vhp_play_server, server, Qnative); |
210 else | |
237 server = ""; | 211 server = ""; |
238 | 212 |
239 /* open audio connection */ | 213 /* open audio connection */ |
240 audio = AOpenAudio( server, &status ); | 214 audio = AOpenAudio( server, &status ); |
241 if( status ) { | 215 if(status) |
242 player_error_internal( audio, "Open audio failed", status ); | 216 { |
217 player_error_internal( audio, "Open audio failed", status ); | |
243 } | 218 } |
244 | 219 |
245 /* replace default error handler */ | 220 /* replace default error handler */ |
246 prevHandler = ASetErrorHandler (myHandler); | 221 prevHandler = ASetErrorHandler (myHandler); |
247 | 222 |
248 /* Create sound bucket */ | 223 /* Create sound bucket */ |
249 header = (SunHeader *) data; | 224 header = (SunHeader *) data; |
250 | 225 |
251 pSBucket = ACreateSBucket(audio, NULL, NULL, &status); | 226 pSBucket = ACreateSBucket(audio, NULL, NULL, &status); |
252 if (status) | 227 if (status) |
253 player_error_internal( audio, "Bucket creation failed", status ); | 228 player_error_internal( audio, "Bucket creation failed", status ); |
254 | 229 |
255 APutSBucketData(audio, pSBucket, 0, (char *) (data + header->header_size), header->data_length, &status); | 230 APutSBucketData(audio, pSBucket, 0, (Char_Binary *) (data + header->header_size), header->data_length, &status); |
256 | 231 |
257 if (status) | 232 if (status) |
258 player_error_internal( audio, "Audio data copy failed", status ); | 233 player_error_internal( audio, "Audio data copy failed", status ); |
259 | 234 |
260 /* Play sound */ | 235 /* Play sound */ |
261 play_bucket_internal(audio, pSBucket, volume); | 236 play_bucket_internal(audio, pSBucket, volume); |
262 | 237 |
263 ASetErrorHandler(prevHandler); | 238 ASetErrorHandler(prevHandler); |
264 if (status) | 239 if (status) |
265 player_error_internal( audio, "Audio data copy failed", status ); | 240 player_error_internal( audio, "Audio data copy failed", status ); |
266 | 241 |
267 return 1; | 242 return 1; |
268 } | 243 } |
269 | 244 |
270 void | 245 void |
271 vars_of_hpplay (void) | 246 vars_of_hpplay (void) |
272 { | 247 { |
286 not make your functions depend on it. | 261 not make your functions depend on it. |
287 */ ); | 262 */ ); |
288 | 263 |
289 Vhp_play_speaker = intern ("internal"); | 264 Vhp_play_speaker = intern ("internal"); |
290 | 265 |
291 DEFVAR_INT("hp-play-gain", &hp_play_gain /* | 266 DEFVAR_INT ("hp-play-gain", &hp_play_gain /* |
292 Global gain value for playing sounds. | 267 Global gain value for playing sounds. |
293 Default value is AUnityGain which means keep level. | 268 Default value is AUnityGain which means keep level. |
294 Please refer to the HP documentation, for instance in | 269 Please refer to the HP documentation, for instance in |
295 `Using the Audio Application Program Interface', for details on how to | 270 `Using the Audio Application Program Interface', for details on how to |
296 interpret this variable. | 271 interpret this variable. |