annotate src/hpplay.c @ 282:c42ec1d1cded r21-0b39

Import from CVS: tag r21-0b39
author cvs
date Mon, 13 Aug 2007 10:33:18 +0200
parents ca9a9ec9c1c1
children b8cc9ab3f761
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1 /* Copyright (C) 1993 Free Software Foundation, Inc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3 This file is part of XEmacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5 XEmacs is free software; you can redistribute it and/or modify it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6 under the terms of the GNU General Public License as published by the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7 Free Software Foundation; either version 2, or (at your option) any
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8 later version.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10 XEmacs is distributed in the hope that it will be useful, but WITHOUT
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 for more details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15 You should have received a copy of the GNU General Public License
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16 along with XEmacs; see the file COPYING. If not, write to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18 Boston, MA 02111-1307, USA. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20 /* Synched up with: Not in FSF. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23 /***
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24 NAME
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25 hpplay
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26 PURPOSE
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27 Play .au sound files on hp9000s700
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28 BUGS
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29 I have been unable to figure out how to use the volume feature, so no
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 attempts has been made to honor the volume arg of play_sound_*
274
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents: 272
diff changeset
31 This means that all sounds are played at 100%.
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents: 272
diff changeset
32 The gain parameter can be set by using the hp-play-gain variable.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34 NOTES
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35 This file is mostly based on the player program found in the examples
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36 directory of the audio software delivered on our machines. The path I
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 found it under was /usr/audio/examples/player.c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 This file contained no credits and no copyrights. The original fileheader
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 82
diff changeset
39 is given below.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40 HISTORY
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41 lynbech - Feb 10, 1993: Created.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 ***/
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 /* ORIGINAL FILEHEADER:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 * player - command-line audio file player
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 * Aug. 28 1991
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 * by three unknown, unsung audio programmers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 * (well, only two are unsung)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 82
diff changeset
51 #include <config.h>
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 82
diff changeset
52 #include "lisp.h"
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 82
diff changeset
53
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 #include <stdlib.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 #include <stdio.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 #ifdef HPUX10
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 #include <Alib.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 #include <CUlib.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 #else /* !HPUX 10 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 #include <audio/Alib.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 #include <audio/CUlib.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 #endif /* !HPUX 10 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64 Lisp_Object Vhp_play_server;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 Lisp_Object Vhp_play_speaker;
274
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents: 272
diff changeset
66 int hp_play_gain;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 /* Functions */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 /* error handling */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 void player_error_internal(
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 Audio * audio,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73 char * text,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74 long errorCode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 char errorbuff[132],buf[256];
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 AGetErrorText(audio, errorCode, errorbuff, 131);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 sprintf(buf,"%s: %s\n",text,errorbuff);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 error(buf);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 long myHandler(audio, err_event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 Audio * audio;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 AErrorEvent * err_event;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 player_error_internal(audio, "Internal sound error", err_event->error_code);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 return 1; /* Must return something, was orig. an exit */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 /* Playing */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 play_bucket_internal(audio, pSBucket, volume)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 Audio *audio;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 SBucket *pSBucket;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 long volume;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 SBPlayParams playParams;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 AGainEntry gainEntry;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 ATransID xid;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 long status;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 char * speaker;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 playParams.priority = APriorityNormal; /* normal priority */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
107 /*
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
108 * We can't signal an error, because all h*ll would break loose if
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
109 * we did.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
110 */
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
111 if (SYMBOLP (Vhp_play_speaker))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
112 {
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
113 speaker = (char *) (string_data (XSYMBOL (Vhp_play_speaker)->name));
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 82
diff changeset
114
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
115 /*
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
116 * setup the playback parameters
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
117 */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
119 /* speaker selection */
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
120 if ( strcmp(speaker,"external") == 0 ) {
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
121 gainEntry.u.o.out_dst = AODTMonoJack;
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
122 } else {
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
123 gainEntry.u.o.out_dst = AODTMonoIntSpeaker;
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
124 }
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
125 }
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
126 else
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
127 {
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
128 /*
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
129 * Quietly revert to the internal speaker
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
130 */
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
131 gainEntry.u.o.out_dst = AODTMonoIntSpeaker;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134 gainEntry.u.o.out_ch = AOCTMono;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 gainEntry.gain = AUnityGain;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 playParams.gain_matrix.type = AGMTOutput; /* gain matrix */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137 playParams.gain_matrix.num_entries = 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 playParams.gain_matrix.gain_entries = &gainEntry;
274
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents: 272
diff changeset
139 playParams.play_volume = hp_play_gain; /* play volume */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 playParams.pause_first = False; /* don't pause */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 playParams.start_offset.type = ATTSamples; /* start offset 0 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142 playParams.start_offset.u.samples = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143 playParams.duration.type = ATTFullLength; /* play entire sample */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144 playParams.loop_count = 1; /* play sample just once */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 playParams.previous_transaction = 0; /* no linked transaction */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 playParams.event_mask = 0; /* don't solicit any events */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 * play the sound bucket
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151 xid = APlaySBucket( audio, pSBucket, &playParams, NULL );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153 /*
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 82
diff changeset
154 * set close mode to prevent playback from stopping
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155 * when we close audio connection
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 ASetCloseDownMode( audio, AKeepTransactions, &status );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160 * That's all, folks!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161 * Always destroy bucket and close connection.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163 ADestroySBucket( audio, pSBucket, &status );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164 ACloseAudio( audio, &status );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168 play_sound_file (sound_file, volume)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169 char * sound_file;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170 int volume;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172 SBucket *pSBucket;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173 Audio *audio;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174 long status;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175 AErrorHandler prevHandler; /* pointer to previous handler */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176 char *server;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178 if (STRINGP(Vhp_play_server))
82
6a378aca36af Import from CVS: tag r20-0b91
cvs
parents: 70
diff changeset
179 server = (char *) XSTRING_DATA (Vhp_play_server);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180 server = "";
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183 * open audio connection
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 audio = AOpenAudio( server, &status );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186 if( status ) {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187 player_error_internal( audio, "Open audio failed", status );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190 /* replace default error handler */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191 prevHandler = ASetErrorHandler(myHandler);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194 * Load the audio file into a sound bucket
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197 pSBucket = ALoadAFile( audio, sound_file, AFFUnknown, 0, NULL, NULL );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200 * Play the bucket
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203 play_bucket_internal(audio, pSBucket, volume);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205 ASetErrorHandler(prevHandler);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210 play_sound_data (data, length, volume)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211 unsigned char * data;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212 int length;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213 int volume;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215 SBucket *pSBucket;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216 Audio *audio;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217 AErrorHandler prevHandler;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218 SunHeader *header;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219 long status;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220 char *server;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222 if (STRINGP (Vhp_play_server))
82
6a378aca36af Import from CVS: tag r20-0b91
cvs
parents: 70
diff changeset
223 server = (char *) XSTRING_DATA (Vhp_play_server);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224 server = "";
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226 /* open audio connection */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227 audio = AOpenAudio( server, &status );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228 if( status ) {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229 player_error_internal( audio, "Open audio failed", status );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232 /* replace default error handler */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233 prevHandler = ASetErrorHandler (myHandler);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235 /* Create sound bucket */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236 header = (SunHeader *) data;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238 pSBucket = ACreateSBucket(audio, NULL, NULL, &status);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239 if (status)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240 player_error_internal( audio, "Bucket creation failed", status );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242 APutSBucketData(audio, pSBucket, 0, (char *) (data + header->header_size), header->data_length, &status);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244 if (status)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245 player_error_internal( audio, "Audio data copy failed", status );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247 /* Play sound */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248 play_bucket_internal(audio, pSBucket, volume);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250 ASetErrorHandler(prevHandler);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251 if (status)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252 player_error_internal( audio, "Audio data copy failed", status );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256 vars_of_hpplay (void)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258 DEFVAR_LISP ("hp-play-server", &Vhp_play_server /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259 A string, determining which server to play sound at.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260 Note that this is specific to the HP sound implementation, and you should
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261 not make your functions depend on it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262 */ );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264 Vhp_play_server = Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
265
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
266 DEFVAR_LISP ("hp-play-speaker", &Vhp_play_speaker /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
267 If this variable is the symbol `external', sound is played externally.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268 If the environment variable SPEAKER is set, that value is used for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
269 initializing this variable.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
270 Note that this is specific to the HP sound implementation, and you should
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
271 not make your functions depend on it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
272 */ );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
273
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
274 Vhp_play_speaker = intern ("internal");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
275
274
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents: 272
diff changeset
276 DEFVAR_INT("hp-play-gain", &hp_play_gain /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
277 Global gain value for playing sounds.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
278 Default value is AUnityGain which means keep level.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
279 Please refer to the HP documentation, for instance in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
280 `Using the Audio Application Program Interface', for details on how to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
281 interpret this variable.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
282 Note that this is specific to the HP sound implementation, and you should
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
283 not make your functions depend on it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
284 */ );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
285
274
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents: 272
diff changeset
286 hp_play_gain = AUnityGain;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
287 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
288
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
289 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
290 init_hpplay (void)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
291 {
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 82
diff changeset
292 if (getenv ("SPEAKER"))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
293 Vhp_play_speaker = intern (getenv ("SPEAKER"));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
294 }