Mercurial > hg > xemacs-beta
annotate src/hpplay.c @ 5842:9e5f3a0d4e66
Add `noerror' optional argument to `live-move'.
2014-12-31 Michael Sperber <mike@xemacs.org>
* simple.el (line-move): Add `noerror' optional argument, as in
GNU Emacs.
author | Mike Sperber <sperber@deinprogramm.de> |
---|---|
date | Sat, 03 Jan 2015 16:24:56 +0100 |
parents | 308d34e9f07d |
children |
rev | line source |
---|---|
428 | 1 /* Copyright (C) 1993 Free Software Foundation, Inc. |
2 | |
3 This file is part of XEmacs. | |
4 | |
5402
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
4981
diff
changeset
|
5 XEmacs is free software: you can redistribute it and/or modify it |
428 | 6 under the terms of the GNU General Public License as published by the |
5402
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
4981
diff
changeset
|
7 Free Software Foundation, either version 3 of the License, or (at your |
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
4981
diff
changeset
|
8 option) any later version. |
428 | 9 |
10 XEmacs is distributed in the hope that it will be useful, but WITHOUT | |
11 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
12 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
13 for more details. | |
14 | |
15 You should have received a copy of the GNU General Public License | |
5402
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
4981
diff
changeset
|
16 along with XEmacs. If not, see <http://www.gnu.org/licenses/>. */ |
428 | 17 |
18 /* Synched up with: Not in FSF. */ | |
19 | |
563 | 20 /* This file Mule-ized by Ben Wing, 5-15-01. */ |
21 | |
428 | 22 |
23 /*** | |
24 NAME | |
25 hpplay | |
26 PURPOSE | |
27 Play .au sound files on hp9000s700 | |
28 BUGS | |
29 I have been unable to figure out how to use the volume feature, so no | |
444 | 30 attempt has been made to honor the volume arg of play_sound_* |
428 | 31 This means that all sounds are played at 100%. |
32 The gain parameter can be set by using the hp-play-gain variable. | |
33 | |
34 NOTES | |
35 This file is mostly based on the player program found in the examples | |
36 directory of the audio software delivered on our machines. The path I | |
37 found it under was /usr/audio/examples/player.c | |
38 This file contained no credits and no copyrights. The original fileheader | |
39 is given below. | |
40 HISTORY | |
41 lynbech - Feb 10, 1993: Created. | |
42 ***/ | |
43 | |
44 /* ORIGINAL FILEHEADER: | |
45 * player - command-line audio file player | |
46 * Aug. 28 1991 | |
47 * by three unknown, unsung audio programmers | |
48 * (well, only two are unsung) | |
49 */ | |
50 | |
51 #include <config.h> | |
52 #include "lisp.h" | |
53 | |
563 | 54 #include "sound.h" |
442 | 55 |
428 | 56 #include <Alib.h> |
57 #include <CUlib.h> | |
58 | |
442 | 59 |
428 | 60 Lisp_Object Vhp_play_server; |
61 Lisp_Object Vhp_play_speaker; | |
458 | 62 Fixnum hp_play_gain; |
428 | 63 |
64 /* Functions */ | |
65 | |
66 /* error handling */ | |
563 | 67 void |
2367 | 68 player_error_internal (Audio * audio, Ascbyte * text, long errorCode) |
428 | 69 { |
563 | 70 Extbyte errorbuff[132]; |
867 | 71 Ibyte *interr; |
428 | 72 |
563 | 73 AGetErrorText (audio, errorCode, errorbuff, 131); |
4981
4aebb0131297
Cleanups/renaming of EXTERNAL_TO_C_STRING and friends
Ben Wing <ben@xemacs.org>
parents:
4953
diff
changeset
|
74 interr = EXTERNAL_TO_ITEXT (errorbuf, Qerror_message_encoding); |
563 | 75 |
4953
304aebb79cd3
function renamings to track names of char typedefs
Ben Wing <ben@xemacs.org>
parents:
4952
diff
changeset
|
76 signal_error (Qsound_error, text, build_istring (interr)); |
428 | 77 } |
78 | |
563 | 79 long |
80 myHandler( Audio * audio, AErrorEvent * err_event) | |
428 | 81 { |
82 player_error_internal(audio, "Internal sound error", err_event->error_code); | |
83 return 1; /* Must return something, was orig. an exit */ | |
84 } | |
85 | |
86 /* Playing */ | |
87 void | |
2286 | 88 play_bucket_internal( Audio *audio, SBucket *pSBucket, long UNUSED (volume)) |
428 | 89 { |
563 | 90 SBPlayParams playParams; |
91 AGainEntry gainEntry; | |
92 ATransID xid; | |
93 long status; | |
94 | |
95 playParams.priority = APriorityNormal; /* normal priority */ | |
428 | 96 |
563 | 97 /* |
98 * We can't signal an error, because all h*ll would break loose if | |
99 * we did. | |
100 */ | |
101 if (EQ (Vhp_play_speaker, Qexternal)) | |
102 gainEntry.u.o.out_dst = AODTMonoJack; | |
103 else | |
104 gainEntry.u.o.out_dst = AODTMonoIntSpeaker; | |
428 | 105 |
563 | 106 gainEntry.u.o.out_ch = AOCTMono; |
107 gainEntry.gain = AUnityGain; | |
108 playParams.gain_matrix.type = AGMTOutput; /* gain matrix */ | |
109 playParams.gain_matrix.num_entries = 1; | |
110 playParams.gain_matrix.gain_entries = &gainEntry; | |
111 playParams.play_volume = hp_play_gain; /* play volume */ | |
112 playParams.pause_first = False; /* don't pause */ | |
113 playParams.start_offset.type = ATTSamples; /* start offset 0 */ | |
114 playParams.start_offset.u.samples = 0; | |
115 playParams.duration.type = ATTFullLength; /* play entire sample */ | |
116 playParams.loop_count = 1; /* play sample just once */ | |
117 playParams.previous_transaction = 0; /* no linked transaction */ | |
118 playParams.event_mask = 0; /* don't solicit any events */ | |
428 | 119 |
563 | 120 /* |
121 * play the sound bucket | |
122 */ | |
123 xid = APlaySBucket( audio, pSBucket, &playParams, NULL ); | |
428 | 124 |
563 | 125 /* |
126 * set close mode to prevent playback from stopping | |
127 * when we close audio connection | |
128 */ | |
129 ASetCloseDownMode( audio, AKeepTransactions, &status ); | |
428 | 130 |
563 | 131 /* |
132 * That's all, folks! | |
133 * Always destroy bucket and close connection. | |
134 */ | |
135 ADestroySBucket( audio, pSBucket, &status ); | |
136 ACloseAudio( audio, &status ); | |
428 | 137 } |
138 | |
139 void | |
563 | 140 play_sound_file (Extbyte * sound_file, int volume) |
428 | 141 { |
563 | 142 sbucket *pSBucket; |
143 Audio *audio; | |
144 long status; | |
145 AErrorHandler prevHandler; /* pointer to previous handler */ | |
146 Extbyte *server; | |
428 | 147 |
563 | 148 if (STRINGP (Vhp_play_server)) |
4981
4aebb0131297
Cleanups/renaming of EXTERNAL_TO_C_STRING and friends
Ben Wing <ben@xemacs.org>
parents:
4953
diff
changeset
|
149 server = LISP_STRING_TO_EXTERNAL (Vhp_play_server, |
4aebb0131297
Cleanups/renaming of EXTERNAL_TO_C_STRING and friends
Ben Wing <ben@xemacs.org>
parents:
4953
diff
changeset
|
150 Qunix_host_name_encoding); |
563 | 151 else |
428 | 152 server = ""; |
153 | |
563 | 154 /* |
155 * open audio connection | |
156 */ | |
157 audio = AOpenAudio( server, &status ); | |
158 if( status ) | |
159 { | |
160 player_error_internal( audio, "Open audio failed", status ); | |
428 | 161 } |
162 | |
563 | 163 /* replace default error handler */ |
164 prevHandler = ASetErrorHandler(myHandler); | |
428 | 165 |
563 | 166 /* |
167 * Load the audio file into a sound bucket | |
168 */ | |
428 | 169 |
563 | 170 pSBucket = ALoadAFile( audio, sound_file, AFFUnknown, 0, NULL, NULL ); |
428 | 171 |
563 | 172 /* |
173 * Play the bucket | |
174 */ | |
428 | 175 |
563 | 176 play_bucket_internal(audio, pSBucket, volume); |
428 | 177 |
563 | 178 ASetErrorHandler(prevHandler); |
428 | 179 } |
180 | |
181 | |
442 | 182 int |
2367 | 183 play_sound_data (Binbyte * data, int UNUSED (length), int volume) |
428 | 184 { |
563 | 185 SBucket *pSBucket; |
186 Audio *audio; | |
187 AErrorHandler prevHandler; | |
188 SunHeader *header; | |
189 long status; | |
190 Extbyte *server; | |
191 int result; | |
428 | 192 |
563 | 193 /* #### Finish this to return an error code. |
194 This function signal a lisp error. How consistent with the rest. | |
195 What if this function is needed in doing the beep for the error? | |
442 | 196 |
563 | 197 Apparently the author of this didn't read the comment in |
198 Fplay_sound. | |
199 */ | |
442 | 200 |
201 | |
563 | 202 if (STRINGP (Vhp_play_server)) |
4981
4aebb0131297
Cleanups/renaming of EXTERNAL_TO_C_STRING and friends
Ben Wing <ben@xemacs.org>
parents:
4953
diff
changeset
|
203 server = LISP_STRING_TO_EXTERNAL (Vhp_play_server, |
4aebb0131297
Cleanups/renaming of EXTERNAL_TO_C_STRING and friends
Ben Wing <ben@xemacs.org>
parents:
4953
diff
changeset
|
204 Qunix_host_name_encoding); |
563 | 205 else |
428 | 206 server = ""; |
207 | |
563 | 208 /* open audio connection */ |
209 audio = AOpenAudio( server, &status ); | |
210 if(status) | |
211 { | |
212 player_error_internal( audio, "Open audio failed", status ); | |
428 | 213 } |
214 | |
563 | 215 /* replace default error handler */ |
216 prevHandler = ASetErrorHandler (myHandler); | |
428 | 217 |
563 | 218 /* Create sound bucket */ |
219 header = (SunHeader *) data; | |
428 | 220 |
563 | 221 pSBucket = ACreateSBucket(audio, NULL, NULL, &status); |
222 if (status) | |
223 player_error_internal( audio, "Bucket creation failed", status ); | |
428 | 224 |
2367 | 225 APutSBucketData(audio, pSBucket, 0, (CBinbyte *) (data + header->header_size), header->data_length, &status); |
428 | 226 |
563 | 227 if (status) |
228 player_error_internal( audio, "Audio data copy failed", status ); | |
428 | 229 |
563 | 230 /* Play sound */ |
231 play_bucket_internal(audio, pSBucket, volume); | |
428 | 232 |
563 | 233 ASetErrorHandler(prevHandler); |
234 if (status) | |
235 player_error_internal( audio, "Audio data copy failed", status ); | |
442 | 236 |
563 | 237 return 1; |
428 | 238 } |
239 | |
240 void | |
241 vars_of_hpplay (void) | |
242 { | |
243 DEFVAR_LISP ("hp-play-server", &Vhp_play_server /* | |
244 A string, determining which server to play sound at. | |
245 Note that this is specific to the HP sound implementation, and you should | |
246 not make your functions depend on it. | |
247 */ ); | |
248 | |
249 Vhp_play_server = Qnil; | |
250 | |
251 DEFVAR_LISP ("hp-play-speaker", &Vhp_play_speaker /* | |
252 If this variable is the symbol `external', sound is played externally. | |
253 If the environment variable SPEAKER is set, that value is used for | |
254 initializing this variable. | |
255 Note that this is specific to the HP sound implementation, and you should | |
256 not make your functions depend on it. | |
257 */ ); | |
258 | |
259 Vhp_play_speaker = intern ("internal"); | |
260 | |
563 | 261 DEFVAR_INT ("hp-play-gain", &hp_play_gain /* |
428 | 262 Global gain value for playing sounds. |
263 Default value is AUnityGain which means keep level. | |
264 Please refer to the HP documentation, for instance in | |
265 `Using the Audio Application Program Interface', for details on how to | |
266 interpret this variable. | |
267 Note that this is specific to the HP sound implementation, and you should | |
268 not make your functions depend on it. | |
269 */ ); | |
270 | |
271 hp_play_gain = AUnityGain; | |
272 } | |
273 | |
274 void | |
275 init_hpplay (void) | |
276 { | |
771 | 277 if (egetenv ("SPEAKER")) |
278 Vhp_play_speaker = intern (egetenv ("SPEAKER")); | |
428 | 279 } |