annotate src/hpplay.c @ 16:0293115a14e9 r19-15b91

Import from CVS: tag r19-15b91
author cvs
date Mon, 13 Aug 2007 08:49:20 +0200
parents ac2d302a0011
children 131b0175ea99
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
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
109 /*
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
110 * 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
111 * we did.
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 if (SYMBOLP (Vhp_play_speaker))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
114 {
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
115 speaker = (char *) (string_data (XSYMBOL (Vhp_play_speaker)->name));
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
117 /*
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
118 * setup the playback parameters
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
119 */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
121 /* speaker selection */
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
122 if ( strcmp(speaker,"external") == 0 ) {
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
123 gainEntry.u.o.out_dst = AODTMonoJack;
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
124 } else {
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
125 gainEntry.u.o.out_dst = AODTMonoIntSpeaker;
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
126 }
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 else
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
129 {
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 * Quietly revert to the internal speaker
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
132 */
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
133 gainEntry.u.o.out_dst = AODTMonoIntSpeaker;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 gainEntry.u.o.out_ch = AOCTMono;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137 gainEntry.gain = AUnityGain;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 playParams.gain_matrix.type = AGMTOutput; /* gain matrix */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139 playParams.gain_matrix.num_entries = 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 playParams.gain_matrix.gain_entries = &gainEntry;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 playParams.play_volume = play_gain; /* play volume */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142 playParams.pause_first = False; /* don't pause */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143 playParams.start_offset.type = ATTSamples; /* start offset 0 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144 playParams.start_offset.u.samples = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 playParams.duration.type = ATTFullLength; /* play entire sample */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 playParams.loop_count = 1; /* play sample just once */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 playParams.previous_transaction = 0; /* no linked transaction */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148 playParams.event_mask = 0; /* don't solicit any events */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151 * play the sound bucket
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153 xid = APlaySBucket( audio, pSBucket, &playParams, NULL );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 * set close mode to prevent playback from stopping
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 * when we close audio connection
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159 ASetCloseDownMode( audio, AKeepTransactions, &status );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162 * That's all, folks!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163 * Always destroy bucket and close connection.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165 ADestroySBucket( audio, pSBucket, &status );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166 ACloseAudio( audio, &status );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170 play_sound_file (sound_file, volume)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171 char * sound_file;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172 int volume;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174 SBucket *pSBucket;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175 Audio *audio;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176 long status;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177 AErrorHandler prevHandler; /* pointer to previous handler */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178 char *server;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180 if (STRINGP(Vhp_play_server))
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
181 server = (char *) XSTRING_DATA (Vhp_play_server);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182 server = "";
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 * open audio connection
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187 audio = AOpenAudio( server, &status );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188 if( status ) {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189 player_error_internal( audio, "Open audio failed", status );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192 /* replace default error handler */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193 prevHandler = ASetErrorHandler(myHandler);
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 * Load the audio file into a sound bucket
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199 pSBucket = ALoadAFile( audio, sound_file, AFFUnknown, 0, NULL, NULL );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202 * Play the bucket
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205 play_bucket_internal(audio, pSBucket, volume);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207 ASetErrorHandler(prevHandler);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212 play_sound_data (data, length, volume)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213 unsigned char * data;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214 int length;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215 int volume;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217 SBucket *pSBucket;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218 Audio *audio;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219 AErrorHandler prevHandler;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220 SunHeader *header;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221 long status;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222 char *server;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224 if (STRINGP (Vhp_play_server))
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
225 server = (char *) XSTRING_DATA (Vhp_play_server);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226 server = "";
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228 /* open audio connection */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229 audio = AOpenAudio( server, &status );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230 if( status ) {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231 player_error_internal( audio, "Open audio failed", status );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234 /* replace default error handler */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235 prevHandler = ASetErrorHandler (myHandler);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237 /* Create sound bucket */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238 header = (SunHeader *) data;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240 pSBucket = ACreateSBucket(audio, NULL, NULL, &status);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241 if (status)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242 player_error_internal( audio, "Bucket creation failed", 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 APutSBucketData(audio, pSBucket, 0, (char *) (data + header->header_size), header->data_length, &status);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246 if (status)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247 player_error_internal( audio, "Audio data copy failed", status );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249 /* Play sound */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250 play_bucket_internal(audio, pSBucket, volume);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252 ASetErrorHandler(prevHandler);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253 if (status)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254 player_error_internal( audio, "Audio data copy failed", status );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258 vars_of_hpplay (void)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260 DEFVAR_LISP ("hp-play-server", &Vhp_play_server /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261 A string, determining which server to play sound at.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262 Note that this is specific to the HP sound implementation, and you should
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263 not make your functions depend on it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264 */ );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
265
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
266 Vhp_play_server = Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
267
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268 DEFVAR_LISP ("hp-play-speaker", &Vhp_play_speaker /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
269 If this variable is the symbol `external', sound is played externally.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
270 If the environment variable SPEAKER is set, that value is used for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
271 initializing this variable.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
272 Note that this is specific to the HP sound implementation, and you should
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
273 not make your functions depend on it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
274 */ );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
275
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
276 Vhp_play_speaker = intern ("internal");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
277
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
278 DEFVAR_INT("hp-play-gain", &play_gain /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
279 Global gain value for playing sounds.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
280 Default value is AUnityGain which means keep level.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
281 Please refer to the HP documentation, for instance in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
282 `Using the Audio Application Program Interface', for details on how to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
283 interpret this variable.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
284 Note that this is specific to the HP sound implementation, and you should
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
285 not make your functions depend on it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
286 */ );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
287
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
288 play_gain = AUnityGain;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
289 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
290
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
291 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
292 init_hpplay (void)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
293 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
294 if (getenv ("SPEAKER"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
295 Vhp_play_speaker = intern (getenv ("SPEAKER"));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
296 }