annotate src/hpplay.c @ 0:376386a54a3c r19-14

Import from CVS: tag r19-14
author cvs
date Mon, 13 Aug 2007 08:45:50 +0200
parents
children ac2d302a0011
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_*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31 This means that all sounds is played at 100%.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 The gain parameter can be set by using the play-gain variable.
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
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39 is given below.
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
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 #include <stdlib.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 #include <stdio.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 #include <config.h> /* to get system rev level. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 #ifdef HPUX10
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 #include <Alib.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 #include <CUlib.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 #else /* !HPUX 10 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 #include <audio/Alib.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 #include <audio/CUlib.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 #endif /* !HPUX 10 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 /* New Symbols */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 #include <config.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64 #include "lisp.h"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 Lisp_Object Vhp_play_server;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 Lisp_Object Vhp_play_speaker;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 int play_gain;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 /* Functions */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 /* error handling */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73 void player_error_internal(
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74 Audio * audio,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 char * text,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76 long errorCode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 char errorbuff[132],buf[256];
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 AGetErrorText(audio, errorCode, errorbuff, 131);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 sprintf(buf,"%s: %s\n",text,errorbuff);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 error(buf);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 long myHandler(audio, err_event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 Audio * audio;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 AErrorEvent * err_event;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 player_error_internal(audio, "Internal sound error", err_event->error_code);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 return 1; /* Must return something, was orig. an exit */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 /* Playing */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 play_bucket_internal(audio, pSBucket, volume)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 Audio *audio;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 SBucket *pSBucket;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 long volume;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 SBPlayParams playParams;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 AGainEntry gainEntry;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 ATransID xid;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 long status;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 char * speaker;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 playParams.priority = APriorityNormal; /* normal priority */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 speaker = (char *) (string_data (XSYMBOL (Vhp_play_speaker)->name));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112 * setup the playback parameters
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 /* speaker selection */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 if ( strcmp(speaker,"external") == 0 ) {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 gainEntry.u.o.out_dst = AODTMonoJack;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118 } else {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119 gainEntry.u.o.out_dst = AODTMonoIntSpeaker;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122 gainEntry.u.o.out_ch = AOCTMono;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123 gainEntry.gain = AUnityGain;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124 playParams.gain_matrix.type = AGMTOutput; /* gain matrix */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125 playParams.gain_matrix.num_entries = 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126 playParams.gain_matrix.gain_entries = &gainEntry;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127 playParams.play_volume = play_gain; /* play volume */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128 playParams.pause_first = False; /* don't pause */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129 playParams.start_offset.type = ATTSamples; /* start offset 0 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130 playParams.start_offset.u.samples = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131 playParams.duration.type = ATTFullLength; /* play entire sample */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132 playParams.loop_count = 1; /* play sample just once */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133 playParams.previous_transaction = 0; /* no linked transaction */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134 playParams.event_mask = 0; /* don't solicit any events */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137 * play the sound bucket
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139 xid = APlaySBucket( audio, pSBucket, &playParams, NULL );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142 * set close mode to prevent playback from stopping
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143 * when we close audio connection
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 ASetCloseDownMode( audio, AKeepTransactions, &status );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148 * That's all, folks!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 * Always destroy bucket and close connection.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151 ADestroySBucket( audio, pSBucket, &status );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152 ACloseAudio( audio, &status );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 play_sound_file (sound_file, volume)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 char * sound_file;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158 int volume;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160 SBucket *pSBucket;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161 Audio *audio;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162 long status;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163 AErrorHandler prevHandler; /* pointer to previous handler */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164 char *server;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166 if (STRINGP(Vhp_play_server))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167 server = (char *) (string_data (XSTRING (Vhp_play_server)));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168 server = "";
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171 * open audio connection
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173 audio = AOpenAudio( server, &status );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174 if( status ) {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175 player_error_internal( audio, "Open audio failed", status );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178 /* replace default error handler */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179 prevHandler = ASetErrorHandler(myHandler);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182 * Load the audio file into a sound bucket
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 pSBucket = ALoadAFile( audio, sound_file, AFFUnknown, 0, NULL, NULL );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188 * Play the bucket
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191 play_bucket_internal(audio, pSBucket, volume);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193 ASetErrorHandler(prevHandler);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194 }
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 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198 play_sound_data (data, length, volume)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199 unsigned char * data;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200 int length;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201 int volume;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203 SBucket *pSBucket;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204 Audio *audio;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205 AErrorHandler prevHandler;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206 SunHeader *header;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207 long status;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208 char *server;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210 if (STRINGP (Vhp_play_server))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211 server = (char *) (string_data (XSTRING (Vhp_play_server)));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212 server = "";
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214 /* open audio connection */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215 audio = AOpenAudio( server, &status );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216 if( status ) {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217 player_error_internal( audio, "Open audio failed", status );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220 /* replace default error handler */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221 prevHandler = ASetErrorHandler (myHandler);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223 /* Create sound bucket */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224 header = (SunHeader *) data;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226 pSBucket = ACreateSBucket(audio, NULL, NULL, &status);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227 if (status)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228 player_error_internal( audio, "Bucket creation failed", status );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230 APutSBucketData(audio, pSBucket, 0, (char *) (data + header->header_size), header->data_length, &status);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232 if (status)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233 player_error_internal( audio, "Audio data copy failed", status );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235 /* Play sound */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236 play_bucket_internal(audio, pSBucket, volume);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238 ASetErrorHandler(prevHandler);
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, "Audio data copy 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
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244 vars_of_hpplay (void)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246 DEFVAR_LISP ("hp-play-server", &Vhp_play_server /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247 A string, determining which server to play sound at.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248 Note that this is specific to the HP sound implementation, and you should
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249 not make your functions depend on it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250 */ );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252 Vhp_play_server = Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254 DEFVAR_LISP ("hp-play-speaker", &Vhp_play_speaker /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255 If this variable is the symbol `external', sound is played externally.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256 If the environment variable SPEAKER is set, that value is used for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257 initializing this variable.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258 Note that this is specific to the HP sound implementation, and you should
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259 not make your functions depend on it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260 */ );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262 Vhp_play_speaker = intern ("internal");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264 DEFVAR_INT("hp-play-gain", &play_gain /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
265 Global gain value for playing sounds.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
266 Default value is AUnityGain which means keep level.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
267 Please refer to the HP documentation, for instance in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268 `Using the Audio Application Program Interface', for details on how to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
269 interpret 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 play_gain = AUnityGain;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
275 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
276
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
277 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
278 init_hpplay (void)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
279 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
280 if (getenv ("SPEAKER"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
281 Vhp_play_speaker = intern (getenv ("SPEAKER"));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
282 }