Mercurial > hg > xemacs-beta
comparison src/libsst.c @ 563:183866b06e0b
[xemacs-hg @ 2001-05-24 07:50:48 by ben]
Makefile.in.in, abbrev.c, alloc.c, buffer.c, bytecode.c, callint.c, callproc.c, casetab.c, chartab.c, cmdloop.c, cmds.c, console-msw.c, console-msw.h, console-stream.c, console-tty.c, console-x.c, console.c, data.c, database.c, debug.c, device-gtk.c, device-msw.c, device-tty.c, device-x.c, device.c, dialog-gtk.c, dialog-msw.c, dialog-x.c, dialog.c, dired-msw.c, dired.c, doc.c, doprnt.c, dragdrop.c, editfns.c, eldap.c, eldap.h, elhash.c, emacs-widget-accessors.c, emacs.c, emodules.c, esd.c, eval.c, event-Xt.c, event-gtk.c, event-msw.c, event-stream.c, events.c, extents.c, faces.c, file-coding.c, fileio.c, filelock.c, floatfns.c, fns.c, font-lock.c, frame-gtk.c, frame-x.c, frame.c, general-slots.h, glade.c, glyphs-gtk.c, glyphs-msw.c, glyphs-widget.c, glyphs-x.c, glyphs.c, glyphs.h, gpmevent.c, gui-gtk.c, gui-x.c, gui.c, gutter.c, hpplay.c, indent.c, input-method-xlib.c, insdel.c, intl.c, keymap.c, libsst.c, libsst.h, linuxplay.c, lisp.h, lread.c, lstream.c, lstream.h, macros.c, marker.c, md5.c, menubar-gtk.c, menubar-msw.c, menubar-x.c, menubar.c, minibuf.c, miscplay.c, miscplay.h, mule-ccl.c, mule-charset.c, mule-wnnfns.c, mule.c, nas.c, ntplay.c, ntproc.c, objects-gtk.c, objects-msw.c, objects-x.c, objects.c, postgresql.c, print.c, process-nt.c, process-unix.c, process.c, ralloc.c, rangetab.c, redisplay.c, scrollbar.c, search.c, select-gtk.c, select-x.c, select.c, sgiplay.c, sheap.c, sound.c, specifier.c, sunplay.c, symbols.c, symeval.h, symsinit.h, syntax.c, sysdep.c, toolbar-msw.c, toolbar.c, tooltalk.c, ui-byhand.c, ui-gtk.c, undo.c, unexaix.c, unexapollo.c, unexconvex.c, unexec.c, widget.c, win32.c, window.c:
-- defsymbol -> DEFSYMBOL.
-- add an error type to all errors.
-- eliminate the error functions in eval.c that let you just
use Qerror as the type.
-- redo the error API to be more consistent, sensibly named,
and easier to use.
-- redo the error hierarchy somewhat. create new errors:
structure-formation-error, gui-error, invalid-constant,
stack-overflow, out-of-memory, process-error, network-error,
sound-error, printing-unreadable-object, base64-conversion-
error; coding-system-error renamed to text-conversion error;
some others.
-- fix Mule problems in error strings in emodules.c, tooltalk.c.
-- fix error handling in mswin open-network-stream.
-- Mule-ize all sound files and clean up the headers.
-- nativesound.h -> sound.h and used for all sound files.
-- move some shared stuff into glyphs-shared.c: first attempt
at eliminating some of the massive GTK code duplication.
xemacs.mak: add glyphs-shared.c.
xemacs-faq.texi: document how to debug X errors
subr.el: fix doc string to reflect reality
author | ben |
---|---|
date | Thu, 24 May 2001 07:51:33 +0000 |
parents | 84b14dcb0985 |
children | 943eaba38521 |
comparison
equal
deleted
inserted
replaced
562:c775bd016b32 | 563:183866b06e0b |
---|---|
13 | 13 |
14 */ | 14 */ |
15 | 15 |
16 /* Synched up with: Not in FSF. */ | 16 /* Synched up with: Not in FSF. */ |
17 | 17 |
18 #ifdef emacs | 18 /* This file Mule-ized by Ben Wing, 5-15-01. */ |
19 | |
19 #include <config.h> | 20 #include <config.h> |
20 #include "lisp.h" | 21 #include "lisp.h" |
21 #endif | 22 |
22 | 23 #include "sound.h" |
23 #include <stdlib.h> | |
24 #include <stdio.h> | |
25 #include <fcntl.h> | |
26 | |
27 #ifdef HAVE_UNISTD_H | |
28 #include <unistd.h> | |
29 #endif | |
30 | 24 |
31 #include "libsst.h" | 25 #include "libsst.h" |
26 | |
27 #include "sysfile.h" | |
28 | |
32 | 29 |
33 #define AUDBUF 1024 | 30 #define AUDBUF 1024 |
34 | 31 |
35 int | 32 int |
36 sst_open(play_level, record_level) | 33 sst_open(play_level, record_level) |
37 int play_level, record_level; | 34 int play_level, record_level; |
38 { | 35 { |
39 int fd, i, gr, ger, gx; | 36 int fd, i, gr, ger, gx; |
40 struct audio_ioctl ai; | 37 struct audio_ioctl ai; |
41 char *ep; | 38 Extbyte *ep; |
42 | 39 |
43 fd = open( "/dev/audio", O_RDWR ); | 40 fd = open( "/dev/audio", O_RDWR ); |
44 if ( fd < 0 ) | 41 if ( fd < 0 ) |
45 { | 42 { |
46 perror( "sst_open: open /dev/audio" ); | 43 sound_perror( "sst_open: open /dev/audio" ); |
47 return( fd ); | 44 return( fd ); |
48 } | 45 } |
49 | 46 |
50 #ifdef AUDIOSETQSIZE /* This no longer exists as of 4.1.2. */ | 47 #ifdef AUDIOSETQSIZE /* This no longer exists as of 4.1.2. */ |
51 | 48 |
52 /* Shrink audio device's queue size, to cut down time delay. */ | 49 /* Shrink audio device's queue size, to cut down time delay. */ |
53 i = AUDBUF; | 50 i = AUDBUF; |
54 if ( ioctl( fd, AUDIOSETQSIZE, &i ) < 0 ) | 51 if ( ioctl( fd, AUDIOSETQSIZE, &i ) < 0 ) |
55 { | 52 { |
56 perror( "sst_open: SETQSIZE" ); | 53 sound_perror( "sst_open: SETQSIZE" ); |
57 return( fd ); | 54 return( fd ); |
58 } | 55 } |
59 #endif /* AUDIOSETQSIZE */ | 56 #endif /* AUDIOSETQSIZE */ |
60 | 57 |
61 /* Set gains. -10 <= ger <= 18, -18 <= gr <= 12, -18 <= gx <= 12. */ | 58 /* Set gains. -10 <= ger <= 18, -18 <= gr <= 12, -18 <= gx <= 12. */ |
65 if ( (ep = getenv( "SST_PLAY" )) != NULL ) | 62 if ( (ep = getenv( "SST_PLAY" )) != NULL ) |
66 { | 63 { |
67 play_level = atoi( ep ); | 64 play_level = atoi( ep ); |
68 if ( play_level < 0 || play_level > 99 ) | 65 if ( play_level < 0 || play_level > 99 ) |
69 { | 66 { |
70 warn( "sst_open: SST_PLAY must be between 0 and 99" ); | 67 sound_warn( "sst_open: SST_PLAY must be between 0 and 99" ); |
71 return( -1 ); | 68 return( -1 ); |
72 } | 69 } |
73 } | 70 } |
74 } | 71 } |
75 if (!record_level) | 72 if (!record_level) |
78 if ( (ep = getenv( "SST_RECORD" )) != NULL ) | 75 if ( (ep = getenv( "SST_RECORD" )) != NULL ) |
79 { | 76 { |
80 record_level = atoi( ep ); | 77 record_level = atoi( ep ); |
81 if ( record_level < 0 || record_level > 99 ) | 78 if ( record_level < 0 || record_level > 99 ) |
82 { | 79 { |
83 warn( "sst_open: SST_RECORD must be between 0 and 99" ); | 80 sound_warn( "sst_open: SST_RECORD must be between 0 and 99" ); |
84 return( -1 ); | 81 return( -1 ); |
85 } | 82 } |
86 } | 83 } |
87 } | 84 } |
88 | 85 |
108 ** the speaker or the earphone jack, depending on SST_EARPHONES. | 105 ** the speaker or the earphone jack, depending on SST_EARPHONES. |
109 */ | 106 */ |
110 ai.control = AUDIO_MAP_MMR2; | 107 ai.control = AUDIO_MAP_MMR2; |
111 if ( ioctl( fd, AUDIOGETREG, &ai ) < 0 ) | 108 if ( ioctl( fd, AUDIOGETREG, &ai ) < 0 ) |
112 { | 109 { |
113 perror( "sst_open: GETREG MMR2" ); | 110 sound_perror( "sst_open: GETREG MMR2" ); |
114 return( -1 ); | 111 return( -1 ); |
115 } | 112 } |
116 if ( (ep = getenv( "SST_EARPHONES" )) != NULL ) | 113 if ( (ep = getenv( "SST_EARPHONES" )) != NULL ) |
117 ai.data[0] &= ~AUDIO_MMR2_BITS_LS; | 114 ai.data[0] &= ~AUDIO_MMR2_BITS_LS; |
118 else | 115 else |
119 ai.data[0] |= AUDIO_MMR2_BITS_LS; | 116 ai.data[0] |= AUDIO_MMR2_BITS_LS; |
120 if ( ioctl( fd, AUDIOSETREG, &ai ) < 0 ) | 117 if ( ioctl( fd, AUDIOSETREG, &ai ) < 0 ) |
121 { | 118 { |
122 perror( "sst_open: SETREG MMR2" ); | 119 sound_perror( "sst_open: SETREG MMR2" ); |
123 return( fd ); | 120 return( fd ); |
124 } | 121 } |
125 | 122 |
126 return fd; | 123 return fd; |
127 } | 124 } |
134 | 131 |
135 ai.control = AUDIO_MAP_MMR1; | 132 ai.control = AUDIO_MAP_MMR1; |
136 ai.data[0] = 0; | 133 ai.data[0] = 0; |
137 if ( ioctl( fd, AUDIOSETREG, &ai ) < 0 ) | 134 if ( ioctl( fd, AUDIOSETREG, &ai ) < 0 ) |
138 { | 135 { |
139 perror( "sst_close: SETREG MMR1" ); | 136 sound_perror( "sst_close: SETREG MMR1" ); |
140 } | 137 } |
141 ai.control = AUDIO_MAP_MMR2; | 138 ai.control = AUDIO_MAP_MMR2; |
142 ai.data[0] = 0; | 139 ai.data[0] = 0; |
143 if ( ioctl( fd, AUDIOSETREG, &ai ) < 0 ) | 140 if ( ioctl( fd, AUDIOSETREG, &ai ) < 0 ) |
144 { | 141 { |
145 perror( "sst_close: SETREG MMR2" ); | 142 sound_perror( "sst_close: SETREG MMR2" ); |
146 } | 143 } |
147 close( fd ); | 144 close( fd ); |
148 } | 145 } |
149 | 146 |
150 /* These are tables of values to be loaded into various gain registers. | 147 /* These are tables of values to be loaded into various gain registers. |
151 */ | 148 */ |
152 | 149 |
153 static unsigned char ger_table[][2] = { | 150 static UChar_Binary ger_table[][2] = { |
154 0xaa, 0xaa, /* -10db */ | 151 0xaa, 0xaa, /* -10db */ |
155 0x79, 0xac, | 152 0x79, 0xac, |
156 0x41, 0x99, | 153 0x41, 0x99, |
157 0x9c, 0xde, | 154 0x9c, 0xde, |
158 0x74, 0x9c, /* -6db */ | 155 0x74, 0x9c, /* -6db */ |
181 0x00, 0x0b, | 178 0x00, 0x0b, |
182 0x00, 0x0f, /* 18db */ | 179 0x00, 0x0f, /* 18db */ |
183 }; | 180 }; |
184 | 181 |
185 | 182 |
186 static unsigned char gr_gx_table[][2] = { | 183 static UChar_Binary gr_gx_table[][2] = { |
187 0x8b, 0x7c, /* -18db */ | 184 0x8b, 0x7c, /* -18db */ |
188 0x8b, 0x35, | 185 0x8b, 0x35, |
189 0x8b, 0x24, | 186 0x8b, 0x24, |
190 0x91, 0x23, | 187 0x91, 0x23, |
191 0x91, 0x2a, | 188 0x91, 0x2a, |
223 { | 220 { |
224 struct audio_ioctl ai; | 221 struct audio_ioctl ai; |
225 | 222 |
226 if ( ( value < -10 ) || ( value > 18 ) ) | 223 if ( ( value < -10 ) || ( value > 18 ) ) |
227 { | 224 { |
228 char buf [255]; | 225 Extbyte buf [255]; |
229 sprintf (buf, "sst_set_ger: GER %d out of range", value); | 226 sprintf (buf, "sst_set_ger: GER %d out of range", value); |
230 warn(buf); | 227 sound_warn(buf); |
231 return; | 228 return; |
232 } | 229 } |
233 | 230 |
234 /* Add 10 to the value to get the index into the table. */ | 231 /* Add 10 to the value to get the index into the table. */ |
235 ai.control = AUDIO_MAP_GER; | 232 ai.control = AUDIO_MAP_GER; |
236 ai.data[0] = ger_table[value + 10][1]; | 233 ai.data[0] = ger_table[value + 10][1]; |
237 ai.data[1] = ger_table[value + 10][0]; | 234 ai.data[1] = ger_table[value + 10][0]; |
238 | 235 |
239 if ( ioctl( fd, AUDIOSETREG, &ai ) < 0 ) | 236 if ( ioctl( fd, AUDIOSETREG, &ai ) < 0 ) |
240 { | 237 { |
241 perror( "sst_set_ger: SETREG GER" ); | 238 sound_perror( "sst_set_ger: SETREG GER" ); |
242 } | 239 } |
243 | 240 |
244 ai.control = AUDIO_MAP_MMR1; | 241 ai.control = AUDIO_MAP_MMR1; |
245 if ( ioctl( fd, AUDIOGETREG, &ai ) < 0 ) | 242 if ( ioctl( fd, AUDIOGETREG, &ai ) < 0 ) |
246 { | 243 { |
247 perror( "sst_set_ger: GETREG MMR1" ); | 244 sound_perror( "sst_set_ger: GETREG MMR1" ); |
248 } | 245 } |
249 ai.data[0] |= AUDIO_MMR1_BITS_LOAD_GER; | 246 ai.data[0] |= AUDIO_MMR1_BITS_LOAD_GER; |
250 if ( ioctl( fd, AUDIOSETREG, &ai ) < 0 ) | 247 if ( ioctl( fd, AUDIOSETREG, &ai ) < 0 ) |
251 { | 248 { |
252 perror( "sst_set_ger: SETREG MMR1" ); | 249 sound_perror( "sst_set_ger: SETREG MMR1" ); |
253 } | 250 } |
254 } | 251 } |
255 | 252 |
256 void | 253 void |
257 sst_set_gr( fd, value ) | 254 sst_set_gr( fd, value ) |
259 { | 256 { |
260 struct audio_ioctl ai; | 257 struct audio_ioctl ai; |
261 | 258 |
262 if ( ( value < -18 ) || ( value > 12 ) ) | 259 if ( ( value < -18 ) || ( value > 12 ) ) |
263 { | 260 { |
264 char buf [255]; | 261 Extbyte buf [255]; |
265 sprintf (buf, "sst_set_gr: GR %d out of range", value); | 262 sprintf (buf, "sst_set_gr: GR %d out of range", value); |
266 warn (buf); | 263 sound_warn (buf); |
267 return; | 264 return; |
268 } | 265 } |
269 | 266 |
270 ai.control = AUDIO_MAP_GR; | 267 ai.control = AUDIO_MAP_GR; |
271 ai.data[0] = gr_gx_table[value + 18][1]; | 268 ai.data[0] = gr_gx_table[value + 18][1]; |
272 ai.data[1] = gr_gx_table[value + 18][0]; | 269 ai.data[1] = gr_gx_table[value + 18][0]; |
273 | 270 |
274 if ( ioctl( fd, AUDIOSETREG, &ai ) < 0 ) | 271 if ( ioctl( fd, AUDIOSETREG, &ai ) < 0 ) |
275 { | 272 { |
276 perror( "sst_set_gr: SETREG GR" ); | 273 sound_perror( "sst_set_gr: SETREG GR" ); |
277 } | 274 } |
278 | 275 |
279 ai.control = AUDIO_MAP_MMR1; | 276 ai.control = AUDIO_MAP_MMR1; |
280 if ( ioctl( fd, AUDIOGETREG, &ai ) < 0 ) | 277 if ( ioctl( fd, AUDIOGETREG, &ai ) < 0 ) |
281 { | 278 { |
282 perror( "sst_set_gr: GETREG MMR1" ); | 279 sound_perror( "sst_set_gr: GETREG MMR1" ); |
283 } | 280 } |
284 ai.data[0] |= AUDIO_MMR1_BITS_LOAD_GR; | 281 ai.data[0] |= AUDIO_MMR1_BITS_LOAD_GR; |
285 if ( ioctl( fd, AUDIOSETREG, &ai ) < 0 ) | 282 if ( ioctl( fd, AUDIOSETREG, &ai ) < 0 ) |
286 { | 283 { |
287 perror( "sst_set_gr: SETREG MMR1" ); | 284 sound_perror( "sst_set_gr: SETREG MMR1" ); |
288 } | 285 } |
289 } | 286 } |
290 | 287 |
291 void | 288 void |
292 sst_set_gx( fd, value ) | 289 sst_set_gx( fd, value ) |
293 int fd, value; | 290 int fd, value; |
294 { | 291 { |
295 struct audio_ioctl ai; | 292 struct audio_ioctl ai; |
296 char buf [255]; | 293 Extbyte buf [255]; |
297 | 294 |
298 if ( ( value < -18 ) || ( value > 12 ) ) | 295 if ( ( value < -18 ) || ( value > 12 ) ) |
299 { | 296 { |
300 sprintf (buf, "sst_set_gx: GX %d out of range", value); | 297 sprintf (buf, "sst_set_gx: GX %d out of range", value); |
301 warn (buf); | 298 sound_warn (buf); |
302 return; | 299 return; |
303 } | 300 } |
304 | 301 |
305 /* We add 18 to get the index into the table, since entry 0 represents | 302 /* We add 18 to get the index into the table, since entry 0 represents |
306 * -18db. | 303 * -18db. |
309 ai.data[0] = gr_gx_table[value + 18][1]; | 306 ai.data[0] = gr_gx_table[value + 18][1]; |
310 ai.data[1] = gr_gx_table[value + 18][0]; | 307 ai.data[1] = gr_gx_table[value + 18][0]; |
311 | 308 |
312 if ( ioctl( fd, AUDIOSETREG, &ai ) < 0 ) | 309 if ( ioctl( fd, AUDIOSETREG, &ai ) < 0 ) |
313 { | 310 { |
314 perror( "sst_set_gx: SETREG GX" ); | 311 sound_perror( "sst_set_gx: SETREG GX" ); |
315 } | 312 } |
316 | 313 |
317 ai.control = AUDIO_MAP_MMR1; | 314 ai.control = AUDIO_MAP_MMR1; |
318 if ( ioctl( fd, AUDIOGETREG, &ai ) < 0 ) | 315 if ( ioctl( fd, AUDIOGETREG, &ai ) < 0 ) |
319 { | 316 { |
320 perror( "sst_set_gx: GETREG MMR1" ); | 317 sound_perror( "sst_set_gx: GETREG MMR1" ); |
321 } | 318 } |
322 ai.data[0] |= AUDIO_MMR1_BITS_LOAD_GX; | 319 ai.data[0] |= AUDIO_MMR1_BITS_LOAD_GX; |
323 if ( ioctl( fd, AUDIOSETREG, &ai ) < 0 ) | 320 if ( ioctl( fd, AUDIOSETREG, &ai ) < 0 ) |
324 { | 321 { |
325 perror( "sst_set_gx: SETREG MMR1" ); | 322 sound_perror( "sst_set_gx: SETREG MMR1" ); |
326 } | 323 } |
327 } | 324 } |
328 | 325 |
329 void | 326 void |
330 sst_tones( fd, dhz1, dhz2, thz, rhz, usec ) | 327 sst_tones( fd, dhz1, dhz2, thz, rhz, usec ) |
331 int fd, dhz1, dhz2, thz, rhz, usec; | 328 int fd, dhz1, dhz2, thz, rhz, usec; |
332 { | 329 { |
333 char buf [255]; | 330 Extbyte buf [255]; |
334 struct audio_ioctl ai; | 331 struct audio_ioctl ai; |
335 int dval1, dval2, tval, rval; | 332 int dval1, dval2, tval, rval; |
336 unsigned char oldmmr2, newmmr2; | 333 UChar_Binary oldmmr2, newmmr2; |
337 | 334 |
338 if ( dhz1 == 0 ) | 335 if ( dhz1 == 0 ) |
339 dval1 = 0; | 336 dval1 = 0; |
340 else | 337 else |
341 { | 338 { |
342 dval1 = ( dhz1 * 128 + 63 ) / 1000; | 339 dval1 = ( dhz1 * 128 + 63 ) / 1000; |
343 if ( ( dval1 < 1 ) || ( dval1 > 255 ) ) | 340 if ( ( dval1 < 1 ) || ( dval1 > 255 ) ) |
344 { | 341 { |
345 sprintf(buf, "sst_tones: dhz1 %d out of range", dhz1 ); | 342 sprintf(buf, "sst_tones: dhz1 %d out of range", dhz1 ); |
346 warn (buf); | 343 sound_warn (buf); |
347 return; | 344 return; |
348 } | 345 } |
349 } | 346 } |
350 | 347 |
351 if ( dhz2 == 0 ) | 348 if ( dhz2 == 0 ) |
354 { | 351 { |
355 dval2 = ( dhz2 * 128 + 63 ) / 1000; | 352 dval2 = ( dhz2 * 128 + 63 ) / 1000; |
356 if ( ( dval2 < 1 ) || ( dval2 > 255 ) ) | 353 if ( ( dval2 < 1 ) || ( dval2 > 255 ) ) |
357 { | 354 { |
358 sprintf(buf, "sst_tones: dhz2 %d out of range", dhz2 ); | 355 sprintf(buf, "sst_tones: dhz2 %d out of range", dhz2 ); |
359 warn (buf); | 356 sound_warn (buf); |
360 return; | 357 return; |
361 } | 358 } |
362 } | 359 } |
363 | 360 |
364 if ( thz == 0 ) | 361 if ( thz == 0 ) |
367 { | 364 { |
368 tval = ( thz * 128 + 63 ) / 2000; | 365 tval = ( thz * 128 + 63 ) / 2000; |
369 if ( ( tval < 1 ) || ( tval > 255 ) ) | 366 if ( ( tval < 1 ) || ( tval > 255 ) ) |
370 { | 367 { |
371 sprintf(buf, "sst_tones: thz %d out of range", thz ); | 368 sprintf(buf, "sst_tones: thz %d out of range", thz ); |
372 warn (buf); | 369 sound_warn (buf); |
373 return; | 370 return; |
374 } | 371 } |
375 } | 372 } |
376 | 373 |
377 if ( rhz == 0 ) | 374 if ( rhz == 0 ) |
380 { | 377 { |
381 rval = ( rhz * 128 + 63 ) / 2000; | 378 rval = ( rhz * 128 + 63 ) / 2000; |
382 if ( ( rval < 1 ) || ( rval > 255 ) ) | 379 if ( ( rval < 1 ) || ( rval > 255 ) ) |
383 { | 380 { |
384 sprintf(buf, "sst_tones: rhz %d out of range", dhz2 ); | 381 sprintf(buf, "sst_tones: rhz %d out of range", dhz2 ); |
385 warn (buf); | 382 sound_warn (buf); |
386 return; | 383 return; |
387 } | 384 } |
388 } | 385 } |
389 | 386 |
390 if ( ( dval1 != 0 || dval2 != 0 ) && ( tval != 0 || rval != 0 ) ) | 387 if ( ( dval1 != 0 || dval2 != 0 ) && ( tval != 0 || rval != 0 ) ) |
391 { | 388 { |
392 sprintf(buf, "sst_tones: cannot use DTMF and TONE or RINGER at the same time", dhz2 ); | 389 sprintf(buf, "sst_tones: cannot use DTMF and TONE or RINGER at the same time", dhz2 ); |
393 warn (buf); | 390 sound_warn (buf); |
394 return; | 391 return; |
395 } | 392 } |
396 | 393 |
397 if ( tval != 0 && rval != 0 ) | 394 if ( tval != 0 && rval != 0 ) |
398 { | 395 { |
399 sprintf(buf, "sst_tones: cannot use TONE and RINGER at the same time", dhz2 ); | 396 sprintf(buf, "sst_tones: cannot use TONE and RINGER at the same time", dhz2 ); |
400 warn (buf); | 397 sound_warn (buf); |
401 return; | 398 return; |
402 } | 399 } |
403 | 400 |
404 ai.control = AUDIO_MAP_MMR2; | 401 ai.control = AUDIO_MAP_MMR2; |
405 if ( ioctl( fd, AUDIOGETREG, &ai ) < 0 ) | 402 if ( ioctl( fd, AUDIOGETREG, &ai ) < 0 ) |
406 { | 403 { |
407 perror( "sst_tones: GETREG MMR2" ); | 404 sound_perror( "sst_tones: GETREG MMR2" ); |
408 } | 405 } |
409 oldmmr2 = newmmr2 = ai.data[0]; | 406 oldmmr2 = newmmr2 = ai.data[0]; |
410 | 407 |
411 if ( dval1 != 0 || dval2 != 0 ) | 408 if ( dval1 != 0 || dval2 != 0 ) |
412 { | 409 { |
414 ai.control = AUDIO_MAP_FTGR; | 411 ai.control = AUDIO_MAP_FTGR; |
415 ai.data[0] = dval1; | 412 ai.data[0] = dval1; |
416 ai.data[1] = dval2; | 413 ai.data[1] = dval2; |
417 if ( ioctl( fd, AUDIOSETREG, &ai ) < 0 ) | 414 if ( ioctl( fd, AUDIOSETREG, &ai ) < 0 ) |
418 { | 415 { |
419 perror( "sst_tones: SETREG FTGR" ); | 416 sound_perror( "sst_tones: SETREG FTGR" ); |
420 } | 417 } |
421 } | 418 } |
422 | 419 |
423 if ( tval != 0 ) | 420 if ( tval != 0 ) |
424 { | 421 { |
426 ai.control = AUDIO_MAP_FTGR; | 423 ai.control = AUDIO_MAP_FTGR; |
427 ai.data[0] = tval; | 424 ai.data[0] = tval; |
428 ai.data[1] = 0; | 425 ai.data[1] = 0; |
429 if ( ioctl( fd, AUDIOSETREG, &ai ) < 0 ) | 426 if ( ioctl( fd, AUDIOSETREG, &ai ) < 0 ) |
430 { | 427 { |
431 perror( "sst_tones: SETREG FTGR" ); | 428 sound_perror( "sst_tones: SETREG FTGR" ); |
432 } | 429 } |
433 } | 430 } |
434 | 431 |
435 if ( rval != 0 ) | 432 if ( rval != 0 ) |
436 { | 433 { |
438 ai.control = AUDIO_MAP_FTGR; | 435 ai.control = AUDIO_MAP_FTGR; |
439 ai.data[0] = rval; | 436 ai.data[0] = rval; |
440 ai.data[1] = 0; | 437 ai.data[1] = 0; |
441 if ( ioctl( fd, AUDIOSETREG, &ai ) < 0 ) | 438 if ( ioctl( fd, AUDIOSETREG, &ai ) < 0 ) |
442 { | 439 { |
443 perror( "sst_tones: SETREG FTGR" ); | 440 sound_perror( "sst_tones: SETREG FTGR" ); |
444 } | 441 } |
445 } | 442 } |
446 | 443 |
447 ai.control = AUDIO_MAP_MMR2; | 444 ai.control = AUDIO_MAP_MMR2; |
448 ai.data[0] = newmmr2; | 445 ai.data[0] = newmmr2; |
449 if ( ioctl( fd, AUDIOSETREG, &ai ) < 0 ) | 446 if ( ioctl( fd, AUDIOSETREG, &ai ) < 0 ) |
450 { | 447 { |
451 perror( "sst_tones: SETREG MMR2" ); | 448 sound_perror( "sst_tones: SETREG MMR2" ); |
452 } | 449 } |
453 | 450 |
454 usleep( usec ); | 451 usleep( usec ); |
455 | 452 |
456 ai.data[0] = oldmmr2; | 453 ai.data[0] = oldmmr2; |
457 if ( ioctl( fd, AUDIOSETREG, &ai ) < 0 ) | 454 if ( ioctl( fd, AUDIOSETREG, &ai ) < 0 ) |
458 { | 455 { |
459 perror( "sst_tones: SETREG MMR2" ); | 456 sound_perror( "sst_tones: SETREG MMR2" ); |
460 } | 457 } |
461 } | 458 } |
462 | 459 |
463 void | 460 void |
464 sst_dtmf( fd, dial, usecper, usecpause ) | 461 sst_dtmf( fd, dial, usecper, usecpause ) |
465 int fd, usecper, usecpause; | 462 int fd, usecper, usecpause; |
466 char *dial; | 463 Extbyte *dial; |
467 { | 464 { |
468 char *cp; | 465 Extbyte *cp; |
469 | 466 |
470 for ( cp = dial; *cp != '\0'; cp++ ) | 467 for ( cp = dial; *cp != '\0'; cp++ ) |
471 { | 468 { |
472 switch ( *cp ) | 469 switch ( *cp ) |
473 { | 470 { |
493 | 490 |
494 case ',': usleep( usecper ); break; /* big pause */ | 491 case ',': usleep( usecper ); break; /* big pause */ |
495 | 492 |
496 default: | 493 default: |
497 { | 494 { |
498 char buf [255]; | 495 Extbyte buf [255]; |
499 sprintf( buf, "sst_dtmf: unknown dialing code '%c'", *cp ); | 496 sprintf( buf, "sst_dtmf: unknown dialing code '%c'", *cp ); |
500 warn (buf); | 497 sound_warn (buf); |
501 } | 498 } |
502 } | 499 } |
503 usleep( usecpause ); | 500 usleep( usecpause ); |
504 } | 501 } |
505 } | 502 } |