annotate src/hpplay.c @ 406:b8cc9ab3f761 r21-2-33

Import from CVS: tag r21-2-33
author cvs
date Mon, 13 Aug 2007 11:17:09 +0200
parents ca9a9ec9c1c1
children 697ef44129c6
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
406
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 274
diff changeset
54 #include "nativesound.h"
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 274
diff changeset
55
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 #include <stdlib.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 #include <stdio.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 #ifdef HPUX10
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 #include <Alib.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 #include <CUlib.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 #else /* !HPUX 10 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 #include <audio/Alib.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 #include <audio/CUlib.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64 #endif /* !HPUX 10 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65
406
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 274
diff changeset
66
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 Lisp_Object Vhp_play_server;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 Lisp_Object Vhp_play_speaker;
274
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents: 272
diff changeset
69 int hp_play_gain;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 /* Functions */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73 /* error handling */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74 void player_error_internal(
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 Audio * audio,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76 char * text,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 long errorCode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 char errorbuff[132],buf[256];
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 AGetErrorText(audio, errorCode, errorbuff, 131);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 sprintf(buf,"%s: %s\n",text,errorbuff);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 error(buf);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 long myHandler(audio, err_event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 Audio * audio;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 AErrorEvent * err_event;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 player_error_internal(audio, "Internal sound error", err_event->error_code);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 return 1; /* Must return something, was orig. an exit */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 /* Playing */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 play_bucket_internal(audio, pSBucket, volume)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 Audio *audio;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 SBucket *pSBucket;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 long volume;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 SBPlayParams playParams;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 AGainEntry gainEntry;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 ATransID xid;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 long status;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 char * speaker;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 playParams.priority = APriorityNormal; /* normal priority */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109
2
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 * 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
112 * we did.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
113 */
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
114 if (SYMBOLP (Vhp_play_speaker))
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 speaker = (char *) (string_data (XSYMBOL (Vhp_play_speaker)->name));
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 82
diff changeset
117
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
118 /*
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
119 * setup the playback parameters
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
120 */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
122 /* speaker selection */
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
123 if ( strcmp(speaker,"external") == 0 ) {
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
124 gainEntry.u.o.out_dst = AODTMonoJack;
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
125 } else {
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
126 gainEntry.u.o.out_dst = AODTMonoIntSpeaker;
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 else
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 /*
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
132 * Quietly revert to the internal speaker
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
133 */
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
134 gainEntry.u.o.out_dst = AODTMonoIntSpeaker;
0
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 gainEntry.u.o.out_ch = AOCTMono;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 gainEntry.gain = AUnityGain;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139 playParams.gain_matrix.type = AGMTOutput; /* gain matrix */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 playParams.gain_matrix.num_entries = 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 playParams.gain_matrix.gain_entries = &gainEntry;
274
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents: 272
diff changeset
142 playParams.play_volume = hp_play_gain; /* play volume */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143 playParams.pause_first = False; /* don't pause */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144 playParams.start_offset.type = ATTSamples; /* start offset 0 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 playParams.start_offset.u.samples = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 playParams.duration.type = ATTFullLength; /* play entire sample */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 playParams.loop_count = 1; /* play sample just once */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148 playParams.previous_transaction = 0; /* no linked transaction */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 playParams.event_mask = 0; /* don't solicit any events */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152 * play the sound bucket
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154 xid = APlaySBucket( audio, pSBucket, &playParams, NULL );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 /*
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 82
diff changeset
157 * set close mode to prevent playback from stopping
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158 * when we close audio connection
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160 ASetCloseDownMode( audio, AKeepTransactions, &status );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163 * That's all, folks!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164 * Always destroy bucket and close connection.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166 ADestroySBucket( audio, pSBucket, &status );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167 ACloseAudio( audio, &status );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171 play_sound_file (sound_file, volume)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172 char * sound_file;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173 int volume;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175 SBucket *pSBucket;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176 Audio *audio;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177 long status;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178 AErrorHandler prevHandler; /* pointer to previous handler */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179 char *server;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181 if (STRINGP(Vhp_play_server))
82
6a378aca36af Import from CVS: tag r20-0b91
cvs
parents: 70
diff changeset
182 server = (char *) XSTRING_DATA (Vhp_play_server);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183 server = "";
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186 * open audio connection
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188 audio = AOpenAudio( server, &status );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189 if( status ) {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190 player_error_internal( audio, "Open audio failed", status );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193 /* replace default error handler */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194 prevHandler = ASetErrorHandler(myHandler);
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 * Load the audio file into a sound bucket
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 pSBucket = ALoadAFile( audio, sound_file, AFFUnknown, 0, NULL, NULL );
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 the bucket
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206 play_bucket_internal(audio, pSBucket, volume);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207
406
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 274
diff changeset
208 ASetErrorHandler(prevHandler);
0
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
406
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 274
diff changeset
212 int
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213 play_sound_data (data, length, volume)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214 unsigned char * data;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215 int length;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216 int volume;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218 SBucket *pSBucket;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219 Audio *audio;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220 AErrorHandler prevHandler;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221 SunHeader *header;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222 long status;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223 char *server;
406
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 274
diff changeset
224 int result;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225
406
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 274
diff changeset
226 /* #### Finish this to return an error code.
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 274
diff changeset
227 This function signal a lisp error. How consistent with the rest.
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 274
diff changeset
228 What if this function is needed in doing the beep for the error?
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 274
diff changeset
229
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 274
diff changeset
230 Apparently the author of this didn't read the comment in
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 274
diff changeset
231 Fplay_sound.
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 274
diff changeset
232 */
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 274
diff changeset
233
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 274
diff changeset
234
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235 if (STRINGP (Vhp_play_server))
82
6a378aca36af Import from CVS: tag r20-0b91
cvs
parents: 70
diff changeset
236 server = (char *) XSTRING_DATA (Vhp_play_server);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237 server = "";
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239 /* open audio connection */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240 audio = AOpenAudio( server, &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, "Open audio 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
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245 /* replace default error handler */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246 prevHandler = ASetErrorHandler (myHandler);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248 /* Create sound bucket */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249 header = (SunHeader *) data;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251 pSBucket = ACreateSBucket(audio, NULL, NULL, &status);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252 if (status)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253 player_error_internal( audio, "Bucket creation failed", status );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255 APutSBucketData(audio, pSBucket, 0, (char *) (data + header->header_size), header->data_length, &status);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257 if (status)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258 player_error_internal( audio, "Audio data copy failed", status );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260 /* Play sound */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261 play_bucket_internal(audio, pSBucket, volume);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263 ASetErrorHandler(prevHandler);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264 if (status)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
265 player_error_internal( audio, "Audio data copy failed", status );
406
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 274
diff changeset
266
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 274
diff changeset
267 return 1;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
269
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
270 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
271 vars_of_hpplay (void)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
272 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
273 DEFVAR_LISP ("hp-play-server", &Vhp_play_server /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
274 A string, determining which server to play sound at.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
275 Note that this is specific to the HP sound implementation, and you should
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
276 not make your functions depend on it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
277 */ );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
278
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
279 Vhp_play_server = Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
280
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
281 DEFVAR_LISP ("hp-play-speaker", &Vhp_play_speaker /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
282 If this variable is the symbol `external', sound is played externally.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
283 If the environment variable SPEAKER is set, that value is used for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
284 initializing this variable.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
285 Note that this is specific to the HP sound implementation, and you should
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
286 not make your functions depend on it.
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 Vhp_play_speaker = intern ("internal");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
290
274
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents: 272
diff changeset
291 DEFVAR_INT("hp-play-gain", &hp_play_gain /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
292 Global gain value for playing sounds.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
293 Default value is AUnityGain which means keep level.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
294 Please refer to the HP documentation, for instance in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
295 `Using the Audio Application Program Interface', for details on how to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
296 interpret this variable.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
297 Note that this is specific to the HP sound implementation, and you should
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
298 not make your functions depend on it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
299 */ );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
300
274
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents: 272
diff changeset
301 hp_play_gain = AUnityGain;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
302 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
303
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
304 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
305 init_hpplay (void)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
306 {
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 82
diff changeset
307 if (getenv ("SPEAKER"))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
308 Vhp_play_speaker = intern (getenv ("SPEAKER"));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
309 }