annotate src/sound.c @ 41843:ab6cfeb406ab

(compilation-error-regexp-alist): Added regexps for RXP. From Reto Stamm <reto@xilinx.com>.
author Miles Bader <miles@gnu.org>
date Thu, 06 Dec 2001 15:24:09 +0000
parents 1622bfdfe454
children c07ef1efb323
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1 /* sound.c -- sound support.
38297
17465a81d1dd Include Emacs' header files with #include "...".
Gerd Moellmann <gerd@gnu.org>
parents: 38215
diff changeset
2 Copyright (C) 1998, 1999, 2001 Free Software Foundation.
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
3
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
4 This file is part of GNU Emacs.
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
5
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
6 GNU Emacs is free software; you can redistribute it and/or modify
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
7 it under the terms of the GNU General Public License as published by
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
8 the Free Software Foundation; either version 2, or (at your option)
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
9 any later version.
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
10
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
11 GNU Emacs is distributed in the hope that it will be useful,
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
14 GNU General Public License for more details.
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
15
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
16 You should have received a copy of the GNU General Public License
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
17 along with GNU Emacs; see the file COPYING. If not, write to
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
19 Boston, MA 02111-1307, USA. */
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
20
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
21 /* Written by Gerd Moellmann <gerd@gnu.org>. Tested with Luigi's
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
22 driver on FreeBSD 2.2.7 with a SoundBlaster 16. */
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
23
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
24 #include <config.h>
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
25
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
26 #if defined HAVE_SOUND
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
27
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
28 #include <fcntl.h>
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
29 #include <unistd.h>
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
30 #include <sys/types.h>
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
31 #include <errno.h>
38297
17465a81d1dd Include Emacs' header files with #include "...".
Gerd Moellmann <gerd@gnu.org>
parents: 38215
diff changeset
32 #include "lisp.h"
17465a81d1dd Include Emacs' header files with #include "...".
Gerd Moellmann <gerd@gnu.org>
parents: 38215
diff changeset
33 #include "dispextern.h"
17465a81d1dd Include Emacs' header files with #include "...".
Gerd Moellmann <gerd@gnu.org>
parents: 38215
diff changeset
34 #include "atimer.h"
38338
c6ff61f9af43 (toplevel): Include <signal.h> and "syssignal.h".
Gerd Moellmann <gerd@gnu.org>
parents: 38297
diff changeset
35 #include <signal.h>
c6ff61f9af43 (toplevel): Include <signal.h> and "syssignal.h".
Gerd Moellmann <gerd@gnu.org>
parents: 38297
diff changeset
36 #include "syssignal.h"
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
37
39969
21d7408e0d86 Include <sys/ioctl.h> also on systems without <soundcard.h>.
Pavel Janík <Pavel@Janik.cz>
parents: 39812
diff changeset
38 #ifndef MSDOS
21d7408e0d86 Include <sys/ioctl.h> also on systems without <soundcard.h>.
Pavel Janík <Pavel@Janik.cz>
parents: 39812
diff changeset
39 #include <sys/ioctl.h>
21d7408e0d86 Include <sys/ioctl.h> also on systems without <soundcard.h>.
Pavel Janík <Pavel@Janik.cz>
parents: 39812
diff changeset
40 #endif
21d7408e0d86 Include <sys/ioctl.h> also on systems without <soundcard.h>.
Pavel Janík <Pavel@Janik.cz>
parents: 39812
diff changeset
41
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
42 /* FreeBSD has machine/soundcard.h. Voxware sound driver docs mention
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
43 sys/soundcard.h. So, let's try whatever's there. */
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
44
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
45 #ifdef HAVE_MACHINE_SOUNDCARD_H
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
46 #include <machine/soundcard.h>
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
47 #endif
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
48 #ifdef HAVE_SYS_SOUNDCARD_H
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
49 #include <sys/soundcard.h>
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
50 #endif
30079
1572612184fc Sound support for NetBSD through "Linux emulation" support:
Ken Raeburn <raeburn@raeburn.org>
parents: 29717
diff changeset
51 #ifdef HAVE_SOUNDCARD_H
1572612184fc Sound support for NetBSD through "Linux emulation" support:
Ken Raeburn <raeburn@raeburn.org>
parents: 29717
diff changeset
52 #include <soundcard.h>
1572612184fc Sound support for NetBSD through "Linux emulation" support:
Ken Raeburn <raeburn@raeburn.org>
parents: 29717
diff changeset
53 #endif
1572612184fc Sound support for NetBSD through "Linux emulation" support:
Ken Raeburn <raeburn@raeburn.org>
parents: 29717
diff changeset
54
1572612184fc Sound support for NetBSD through "Linux emulation" support:
Ken Raeburn <raeburn@raeburn.org>
parents: 29717
diff changeset
55 #ifndef DEFAULT_SOUND_DEVICE
1572612184fc Sound support for NetBSD through "Linux emulation" support:
Ken Raeburn <raeburn@raeburn.org>
parents: 29717
diff changeset
56 #define DEFAULT_SOUND_DEVICE "/dev/dsp"
1572612184fc Sound support for NetBSD through "Linux emulation" support:
Ken Raeburn <raeburn@raeburn.org>
parents: 29717
diff changeset
57 #endif
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
58
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
59 #define abs(X) ((X) < 0 ? -(X) : (X))
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
60
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
61 /* Structure forward declarations. */
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
62
27146
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
63 struct sound;
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
64 struct sound_device;
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
65
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
66 /* The file header of RIFF-WAVE files (*.wav). Files are always in
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
67 little-endian byte-order. */
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
68
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
69 struct wav_header
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
70 {
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
71 u_int32_t magic;
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
72 u_int32_t length;
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
73 u_int32_t chunk_type;
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
74 u_int32_t chunk_format;
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
75 u_int32_t chunk_length;
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
76 u_int16_t format;
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
77 u_int16_t channels;
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
78 u_int32_t sample_rate;
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
79 u_int32_t bytes_per_second;
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
80 u_int16_t sample_size;
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
81 u_int16_t precision;
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
82 u_int32_t chunk_data;
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
83 u_int32_t data_length;
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
84 };
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
85
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
86 /* The file header of Sun adio files (*.au). Files are always in
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
87 big-endian byte-order. */
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
88
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
89 struct au_header
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
90 {
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
91 /* ASCII ".snd" */
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
92 u_int32_t magic_number;
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
93
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
94 /* Offset of data part from start of file. Minimum value is 24. */
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
95 u_int32_t data_offset;
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
96
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
97 /* Size of data part, 0xffffffff if unknown. */
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
98 u_int32_t data_size;
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
99
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
100 /* Data encoding format.
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
101 1 8-bit ISDN u-law
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
102 2 8-bit linear PCM (REF-PCM)
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
103 3 16-bit linear PCM
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
104 4 24-bit linear PCM
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
105 5 32-bit linear PCM
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
106 6 32-bit IEEE floating-point
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
107 7 64-bit IEEE floating-point
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
108 23 8-bit u-law compressed using CCITT 0.721 ADPCM voice data
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
109 encoding scheme. */
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
110 u_int32_t encoding;
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
111
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
112 /* Number of samples per second. */
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
113 u_int32_t sample_rate;
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
114
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
115 /* Number of interleaved channels. */
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
116 u_int32_t channels;
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
117 };
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
118
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
119 /* Maximum of all sound file headers sizes. */
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
120
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
121 #define MAX_SOUND_HEADER_BYTES \
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
122 max (sizeof (struct wav_header), sizeof (struct au_header))
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
123
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
124 /* Interface structure for sound devices. */
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
125
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
126 struct sound_device
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
127 {
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
128 /* The name of the device or null meaning use a default device name. */
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
129 char *file;
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
130
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
131 /* File descriptor of the device. */
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
132 int fd;
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
133
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
134 /* Device-dependent format. */
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
135 int format;
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
136
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
137 /* Volume (0..100). Zero means unspecified. */
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
138 int volume;
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
139
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
140 /* Sample size. */
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
141 int sample_size;
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
142
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
143 /* Sample rate. */
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
144 int sample_rate;
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
145
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
146 /* Bytes per second. */
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
147 int bps;
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
148
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
149 /* 1 = mono, 2 = stereo, 0 = don't set. */
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
150 int channels;
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
151
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
152 /* Open device SD. */
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
153 void (* open) P_ ((struct sound_device *sd));
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
154
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
155 /* Close device SD. */
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
156 void (* close) P_ ((struct sound_device *sd));
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
157
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
158 /* Configure SD accoring to device-dependent parameters. */
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
159 void (* configure) P_ ((struct sound_device *device));
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
160
27146
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
161 /* Choose a device-dependent format for outputting sound S. */
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
162 void (* choose_format) P_ ((struct sound_device *sd,
27146
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
163 struct sound *s));
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
164
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
165 /* Write NYBTES bytes from BUFFER to device SD. */
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
166 void (* write) P_ ((struct sound_device *sd, char *buffer, int nbytes));
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
167
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
168 /* A place for devices to store additional data. */
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
169 void *data;
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
170 };
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
171
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
172 /* An enumerator for each supported sound file type. */
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
173
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
174 enum sound_type
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
175 {
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
176 RIFF,
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
177 SUN_AUDIO
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
178 };
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
179
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
180 /* Interface structure for sound files. */
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
181
27146
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
182 struct sound
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
183 {
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
184 /* The type of the file. */
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
185 enum sound_type type;
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
186
27146
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
187 /* File descriptor of a sound file. */
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
188 int fd;
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
189
27146
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
190 /* Pointer to sound file header. This contains header_size bytes
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
191 read from the start of a sound file. */
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
192 char *header;
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
193
27146
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
194 /* Number of bytes raed from sound file. This is always <=
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
195 MAX_SOUND_HEADER_BYTES. */
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
196 int header_size;
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
197
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
198 /* Sound data, if a string. */
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
199 Lisp_Object data;
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
200
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
201 /* Play sound file S on device SD. */
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
202 void (* play) P_ ((struct sound *s, struct sound_device *sd));
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
203 };
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
204
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
205 /* Indices of attributes in a sound attributes vector. */
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
206
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
207 enum sound_attr
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
208 {
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
209 SOUND_FILE,
27146
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
210 SOUND_DATA,
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
211 SOUND_DEVICE,
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
212 SOUND_VOLUME,
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
213 SOUND_ATTR_SENTINEL
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
214 };
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
215
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
216 /* Symbols. */
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
217
27146
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
218 extern Lisp_Object QCfile, QCdata;
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
219 Lisp_Object QCvolume, QCdevice;
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
220 Lisp_Object Qsound;
25548
df6548ca33fd (Qplay_sound_functions): Replaces Qplay_sound_hook.
Gerd Moellmann <gerd@gnu.org>
parents: 25003
diff changeset
221 Lisp_Object Qplay_sound_functions;
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
222
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
223 /* These are set during `play-sound' so that sound_cleanup has
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
224 access to them. */
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
225
27146
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
226 struct sound_device *current_sound_device;
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
227 struct sound *current_sound;
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
228
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
229 /* Function prototypes. */
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
230
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
231 static void vox_open P_ ((struct sound_device *));
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
232 static void vox_configure P_ ((struct sound_device *));
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
233 static void vox_close P_ ((struct sound_device *sd));
27146
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
234 static void vox_choose_format P_ ((struct sound_device *, struct sound *));
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
235 static void vox_init P_ ((struct sound_device *));
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
236 static void vox_write P_ ((struct sound_device *, char *, int));
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
237 static void sound_perror P_ ((char *));
40364
f7b039994118 (sound_perror): Unblock SIGIO, turn on atimers.
Gerd Moellmann <gerd@gnu.org>
parents: 40123
diff changeset
238 static void sound_warning P_ ((char *));
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
239 static int parse_sound P_ ((Lisp_Object, Lisp_Object *));
27146
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
240 static void find_sound_type P_ ((struct sound *));
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
241 static u_int32_t le2hl P_ ((u_int32_t));
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
242 static u_int16_t le2hs P_ ((u_int16_t));
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
243 static u_int32_t be2hl P_ ((u_int32_t));
27146
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
244 static int wav_init P_ ((struct sound *));
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
245 static void wav_play P_ ((struct sound *, struct sound_device *));
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
246 static int au_init P_ ((struct sound *));
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
247 static void au_play P_ ((struct sound *, struct sound_device *));
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
248
25722
2be6ced279d3 (Fplay_sound): Remove usused variables.
Gerd Moellmann <gerd@gnu.org>
parents: 25548
diff changeset
249 #if 0 /* Currently not used. */
2be6ced279d3 (Fplay_sound): Remove usused variables.
Gerd Moellmann <gerd@gnu.org>
parents: 25548
diff changeset
250 static u_int16_t be2hs P_ ((u_int16_t));
2be6ced279d3 (Fplay_sound): Remove usused variables.
Gerd Moellmann <gerd@gnu.org>
parents: 25548
diff changeset
251 #endif
2be6ced279d3 (Fplay_sound): Remove usused variables.
Gerd Moellmann <gerd@gnu.org>
parents: 25548
diff changeset
252
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
253
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
254
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
255 /***********************************************************************
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
256 General
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
257 ***********************************************************************/
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
258
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
259 /* Like perror, but signals an error. */
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
260
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
261 static void
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
262 sound_perror (msg)
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
263 char *msg;
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
264 {
40745
1622bfdfe454 (sound_perror): Save errno from being clobbered.
Andreas Schwab <schwab@suse.de>
parents: 40364
diff changeset
265 int saved_errno = errno;
1622bfdfe454 (sound_perror): Save errno from being clobbered.
Andreas Schwab <schwab@suse.de>
parents: 40364
diff changeset
266
40364
f7b039994118 (sound_perror): Unblock SIGIO, turn on atimers.
Gerd Moellmann <gerd@gnu.org>
parents: 40123
diff changeset
267 turn_on_atimers (1);
f7b039994118 (sound_perror): Unblock SIGIO, turn on atimers.
Gerd Moellmann <gerd@gnu.org>
parents: 40123
diff changeset
268 #ifdef SIGIO
f7b039994118 (sound_perror): Unblock SIGIO, turn on atimers.
Gerd Moellmann <gerd@gnu.org>
parents: 40123
diff changeset
269 sigunblock (sigmask (SIGIO));
f7b039994118 (sound_perror): Unblock SIGIO, turn on atimers.
Gerd Moellmann <gerd@gnu.org>
parents: 40123
diff changeset
270 #endif
40745
1622bfdfe454 (sound_perror): Save errno from being clobbered.
Andreas Schwab <schwab@suse.de>
parents: 40364
diff changeset
271 if (saved_errno != 0)
1622bfdfe454 (sound_perror): Save errno from being clobbered.
Andreas Schwab <schwab@suse.de>
parents: 40364
diff changeset
272 error ("%s: %s", msg, strerror (saved_errno));
40364
f7b039994118 (sound_perror): Unblock SIGIO, turn on atimers.
Gerd Moellmann <gerd@gnu.org>
parents: 40123
diff changeset
273 else
f7b039994118 (sound_perror): Unblock SIGIO, turn on atimers.
Gerd Moellmann <gerd@gnu.org>
parents: 40123
diff changeset
274 error ("%s", msg);
f7b039994118 (sound_perror): Unblock SIGIO, turn on atimers.
Gerd Moellmann <gerd@gnu.org>
parents: 40123
diff changeset
275 }
f7b039994118 (sound_perror): Unblock SIGIO, turn on atimers.
Gerd Moellmann <gerd@gnu.org>
parents: 40123
diff changeset
276
f7b039994118 (sound_perror): Unblock SIGIO, turn on atimers.
Gerd Moellmann <gerd@gnu.org>
parents: 40123
diff changeset
277
f7b039994118 (sound_perror): Unblock SIGIO, turn on atimers.
Gerd Moellmann <gerd@gnu.org>
parents: 40123
diff changeset
278 /* Display a warning message. */
f7b039994118 (sound_perror): Unblock SIGIO, turn on atimers.
Gerd Moellmann <gerd@gnu.org>
parents: 40123
diff changeset
279
f7b039994118 (sound_perror): Unblock SIGIO, turn on atimers.
Gerd Moellmann <gerd@gnu.org>
parents: 40123
diff changeset
280 static void
f7b039994118 (sound_perror): Unblock SIGIO, turn on atimers.
Gerd Moellmann <gerd@gnu.org>
parents: 40123
diff changeset
281 sound_warning (msg)
f7b039994118 (sound_perror): Unblock SIGIO, turn on atimers.
Gerd Moellmann <gerd@gnu.org>
parents: 40123
diff changeset
282 char *msg;
f7b039994118 (sound_perror): Unblock SIGIO, turn on atimers.
Gerd Moellmann <gerd@gnu.org>
parents: 40123
diff changeset
283 {
f7b039994118 (sound_perror): Unblock SIGIO, turn on atimers.
Gerd Moellmann <gerd@gnu.org>
parents: 40123
diff changeset
284 message (msg);
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
285 }
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
286
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
287
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
288 /* Parse sound specification SOUND, and fill ATTRS with what is
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
289 found. Value is non-zero if SOUND Is a valid sound specification.
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
290 A valid sound specification is a list starting with the symbol
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
291 `sound'. The rest of the list is a property list which may
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
292 contain the following key/value pairs:
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
293
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
294 - `:file FILE'
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
295
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
296 FILE is the sound file to play. If it isn't an absolute name,
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
297 it's searched under `data-directory'.
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
298
27146
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
299 - `:data DATA'
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
300
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
301 DATA is a string containing sound data. Either :file or :data
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
302 may be present, but not both.
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
303
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
304 - `:device DEVICE'
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
305
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
306 DEVICE is the name of the device to play on, e.g. "/dev/dsp2".
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
307 If not specified, a default device is used.
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
308
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
309 - `:volume VOL'
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
310
25548
df6548ca33fd (Qplay_sound_functions): Replaces Qplay_sound_hook.
Gerd Moellmann <gerd@gnu.org>
parents: 25003
diff changeset
311 VOL must be an integer in the range [0, 100], or a float in the
df6548ca33fd (Qplay_sound_functions): Replaces Qplay_sound_hook.
Gerd Moellmann <gerd@gnu.org>
parents: 25003
diff changeset
312 range [0, 1]. */
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
313
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
314 static int
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
315 parse_sound (sound, attrs)
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
316 Lisp_Object sound;
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
317 Lisp_Object *attrs;
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
318 {
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
319 /* SOUND must be a list starting with the symbol `sound'. */
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
320 if (!CONSP (sound) || !EQ (XCAR (sound), Qsound))
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
321 return 0;
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
322
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
323 sound = XCDR (sound);
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
324 attrs[SOUND_FILE] = Fplist_get (sound, QCfile);
27146
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
325 attrs[SOUND_DATA] = Fplist_get (sound, QCdata);
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
326 attrs[SOUND_DEVICE] = Fplist_get (sound, QCdevice);
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
327 attrs[SOUND_VOLUME] = Fplist_get (sound, QCvolume);
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
328
27146
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
329 /* File name or data must be specified. */
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
330 if (!STRINGP (attrs[SOUND_FILE])
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
331 && !STRINGP (attrs[SOUND_DATA]))
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
332 return 0;
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
333
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
334 /* Volume must be in the range 0..100 or unspecified. */
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
335 if (!NILP (attrs[SOUND_VOLUME]))
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
336 {
25548
df6548ca33fd (Qplay_sound_functions): Replaces Qplay_sound_hook.
Gerd Moellmann <gerd@gnu.org>
parents: 25003
diff changeset
337 if (INTEGERP (attrs[SOUND_VOLUME]))
df6548ca33fd (Qplay_sound_functions): Replaces Qplay_sound_hook.
Gerd Moellmann <gerd@gnu.org>
parents: 25003
diff changeset
338 {
df6548ca33fd (Qplay_sound_functions): Replaces Qplay_sound_hook.
Gerd Moellmann <gerd@gnu.org>
parents: 25003
diff changeset
339 if (XINT (attrs[SOUND_VOLUME]) < 0
df6548ca33fd (Qplay_sound_functions): Replaces Qplay_sound_hook.
Gerd Moellmann <gerd@gnu.org>
parents: 25003
diff changeset
340 || XINT (attrs[SOUND_VOLUME]) > 100)
df6548ca33fd (Qplay_sound_functions): Replaces Qplay_sound_hook.
Gerd Moellmann <gerd@gnu.org>
parents: 25003
diff changeset
341 return 0;
df6548ca33fd (Qplay_sound_functions): Replaces Qplay_sound_hook.
Gerd Moellmann <gerd@gnu.org>
parents: 25003
diff changeset
342 }
df6548ca33fd (Qplay_sound_functions): Replaces Qplay_sound_hook.
Gerd Moellmann <gerd@gnu.org>
parents: 25003
diff changeset
343 else if (FLOATP (attrs[SOUND_VOLUME]))
df6548ca33fd (Qplay_sound_functions): Replaces Qplay_sound_hook.
Gerd Moellmann <gerd@gnu.org>
parents: 25003
diff changeset
344 {
df6548ca33fd (Qplay_sound_functions): Replaces Qplay_sound_hook.
Gerd Moellmann <gerd@gnu.org>
parents: 25003
diff changeset
345 if (XFLOAT_DATA (attrs[SOUND_VOLUME]) < 0
df6548ca33fd (Qplay_sound_functions): Replaces Qplay_sound_hook.
Gerd Moellmann <gerd@gnu.org>
parents: 25003
diff changeset
346 || XFLOAT_DATA (attrs[SOUND_VOLUME]) > 1)
df6548ca33fd (Qplay_sound_functions): Replaces Qplay_sound_hook.
Gerd Moellmann <gerd@gnu.org>
parents: 25003
diff changeset
347 return 0;
df6548ca33fd (Qplay_sound_functions): Replaces Qplay_sound_hook.
Gerd Moellmann <gerd@gnu.org>
parents: 25003
diff changeset
348 }
df6548ca33fd (Qplay_sound_functions): Replaces Qplay_sound_hook.
Gerd Moellmann <gerd@gnu.org>
parents: 25003
diff changeset
349 else
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
350 return 0;
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
351 }
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
352
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
353 /* Device must be a string or unspecified. */
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
354 if (!NILP (attrs[SOUND_DEVICE])
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
355 && !STRINGP (attrs[SOUND_DEVICE]))
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
356 return 0;
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
357
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
358 return 1;
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
359 }
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
360
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
361
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
362 /* Find out the type of the sound file whose file descriptor is FD.
27146
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
363 S is the sound file structure to fill in. */
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
364
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
365 static void
27146
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
366 find_sound_type (s)
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
367 struct sound *s;
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
368 {
27146
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
369 if (!wav_init (s) && !au_init (s))
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
370 error ("Unknown sound format");
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
371 }
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
372
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
373
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
374 /* Function installed by play-sound with record_unwind_protect. */
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
375
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
376 static Lisp_Object
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
377 sound_cleanup (arg)
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
378 Lisp_Object arg;
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
379 {
27146
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
380 if (current_sound_device)
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
381 {
27635
8344762c0da2 * sound.c (sound_cleanup): Don't call device close routine if pointer is null.
Ken Raeburn <raeburn@raeburn.org>
parents: 27315
diff changeset
382 if (current_sound_device->close)
8344762c0da2 * sound.c (sound_cleanup): Don't call device close routine if pointer is null.
Ken Raeburn <raeburn@raeburn.org>
parents: 27315
diff changeset
383 current_sound_device->close (current_sound_device);
27146
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
384 if (current_sound->fd > 0)
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
385 emacs_close (current_sound->fd);
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
386 }
34255
cb2b0d1799db (vox_configure): Set volume for left and right channel.
Gerd Moellmann <gerd@gnu.org>
parents: 31587
diff changeset
387
cb2b0d1799db (vox_configure): Set volume for left and right channel.
Gerd Moellmann <gerd@gnu.org>
parents: 31587
diff changeset
388 return Qnil;
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
389 }
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
390
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
391
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
392 DEFUN ("play-sound", Fplay_sound, Splay_sound, 1, 1, 0,
40123
e528f2adeed4 Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents: 39969
diff changeset
393 doc: /* Play sound SOUND.
e528f2adeed4 Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents: 39969
diff changeset
394 SOUND is a list of the form `(sound KEYWORD VALUE...)'.
e528f2adeed4 Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents: 39969
diff changeset
395 The following keywords are recognized:
e528f2adeed4 Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents: 39969
diff changeset
396
e528f2adeed4 Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents: 39969
diff changeset
397 :file FILE.- read sound data from FILE. If FILE isn't an
e528f2adeed4 Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents: 39969
diff changeset
398 absolute file name, it is searched in `data-directory'.
e528f2adeed4 Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents: 39969
diff changeset
399
e528f2adeed4 Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents: 39969
diff changeset
400 :data DATA - read sound data from string DATA.
e528f2adeed4 Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents: 39969
diff changeset
401
e528f2adeed4 Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents: 39969
diff changeset
402 Exactly one of :file or :data must be present.
e528f2adeed4 Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents: 39969
diff changeset
403
e528f2adeed4 Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents: 39969
diff changeset
404 :volume VOL - set volume to VOL. VOL must an integer in the
e528f2adeed4 Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents: 39969
diff changeset
405 range 0..100 or a float in the range 0..1.0. If not specified,
e528f2adeed4 Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents: 39969
diff changeset
406 don't change the volume setting of the sound device.
e528f2adeed4 Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents: 39969
diff changeset
407
e528f2adeed4 Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents: 39969
diff changeset
408 :device DEVICE - play sound on DEVICE. If not specified,
e528f2adeed4 Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents: 39969
diff changeset
409 a system-dependent default device name is used. */)
e528f2adeed4 Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents: 39969
diff changeset
410 (sound)
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
411 Lisp_Object sound;
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
412 {
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
413 Lisp_Object attrs[SOUND_ATTR_SENTINEL];
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
414 Lisp_Object file;
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
415 struct gcpro gcpro1, gcpro2;
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
416 struct sound_device sd;
27146
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
417 struct sound s;
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
418 Lisp_Object args[2];
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
419 int count = specpdl_ptr - specpdl;
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
420
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
421 file = Qnil;
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
422 GCPRO2 (sound, file);
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
423 bzero (&sd, sizeof sd);
27146
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
424 bzero (&s, sizeof s);
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
425 current_sound_device = &sd;
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
426 current_sound = &s;
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
427 record_unwind_protect (sound_cleanup, Qnil);
27146
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
428 s.header = (char *) alloca (MAX_SOUND_HEADER_BYTES);
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
429
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
430 /* Parse the sound specification. Give up if it is invalid. */
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
431 if (!parse_sound (sound, attrs))
27146
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
432 error ("Invalid sound specification");
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
433
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
434 if (STRINGP (attrs[SOUND_FILE]))
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
435 {
27146
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
436 /* Open the sound file. */
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
437 s.fd = openp (Fcons (Vdata_directory, Qnil),
39812
66e0816837a8 Update calls to openp.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 39682
diff changeset
438 attrs[SOUND_FILE], Qnil, &file, 0);
27146
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
439 if (s.fd < 0)
40364
f7b039994118 (sound_perror): Unblock SIGIO, turn on atimers.
Gerd Moellmann <gerd@gnu.org>
parents: 40123
diff changeset
440 sound_perror ("Could not open sound file");
27146
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
441
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
442 /* Read the first bytes from the file. */
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
443 s.header_size = emacs_read (s.fd, s.header, MAX_SOUND_HEADER_BYTES);
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
444 if (s.header_size < 0)
40364
f7b039994118 (sound_perror): Unblock SIGIO, turn on atimers.
Gerd Moellmann <gerd@gnu.org>
parents: 40123
diff changeset
445 sound_perror ("Invalid sound file header");
27146
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
446 }
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
447 else
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
448 {
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
449 s.data = attrs[SOUND_DATA];
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
450 bcopy (XSTRING (s.data)->data, s.header,
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
451 min (MAX_SOUND_HEADER_BYTES, STRING_BYTES (XSTRING (s.data))));
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
452 }
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
453
27146
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
454 /* Find out the type of sound. Give up if we can't tell. */
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
455 find_sound_type (&s);
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
456
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
457 /* Set up a device. */
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
458 if (STRINGP (attrs[SOUND_DEVICE]))
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
459 {
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
460 int len = XSTRING (attrs[SOUND_DEVICE])->size;
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
461 sd.file = (char *) alloca (len + 1);
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
462 strcpy (sd.file, XSTRING (attrs[SOUND_DEVICE])->data);
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
463 }
27146
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
464
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
465 if (INTEGERP (attrs[SOUND_VOLUME]))
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
466 sd.volume = XFASTINT (attrs[SOUND_VOLUME]);
25548
df6548ca33fd (Qplay_sound_functions): Replaces Qplay_sound_hook.
Gerd Moellmann <gerd@gnu.org>
parents: 25003
diff changeset
467 else if (FLOATP (attrs[SOUND_VOLUME]))
df6548ca33fd (Qplay_sound_functions): Replaces Qplay_sound_hook.
Gerd Moellmann <gerd@gnu.org>
parents: 25003
diff changeset
468 sd.volume = XFLOAT_DATA (attrs[SOUND_VOLUME]) * 100;
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
469
25548
df6548ca33fd (Qplay_sound_functions): Replaces Qplay_sound_hook.
Gerd Moellmann <gerd@gnu.org>
parents: 25003
diff changeset
470 args[0] = Qplay_sound_functions;
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
471 args[1] = sound;
29717
acaa36b47f50 fix up more Lisp_Object/int conversion issues
Ken Raeburn <raeburn@raeburn.org>
parents: 27635
diff changeset
472 Frun_hook_with_args (2, args);
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
473
27146
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
474 /* There is only one type of device we currently support, the VOX
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
475 sound driver. Set up the device interface functions for that
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
476 device. */
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
477 vox_init (&sd);
27146
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
478
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
479 /* Open the device. */
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
480 sd.open (&sd);
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
481
27146
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
482 /* Play the sound. */
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
483 s.play (&s, &sd);
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
484
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
485 /* Close the input file, if any. */
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
486 if (!STRINGP (s.data))
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
487 {
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
488 emacs_close (s.fd);
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
489 s.fd = -1;
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
490 }
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
491
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
492 /* Close the device. */
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
493 sd.close (&sd);
27146
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
494
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
495 /* Clean up. */
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
496 current_sound_device = NULL;
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
497 current_sound = NULL;
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
498 UNGCPRO;
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
499 unbind_to (count, Qnil);
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
500 return Qnil;
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
501 }
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
502
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
503
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
504 /***********************************************************************
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
505 Byte-order Conversion
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
506 ***********************************************************************/
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
507
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
508 /* Convert 32-bit value VALUE which is in little-endian byte-order
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
509 to host byte-order. */
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
510
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
511 static u_int32_t
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
512 le2hl (value)
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
513 u_int32_t value;
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
514 {
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
515 #ifdef WORDS_BIG_ENDIAN
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
516 unsigned char *p = (unsigned char *) &value;
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
517 value = p[0] + (p[1] << 8) + (p[2] << 16) + (p[3] << 24);
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
518 #endif
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
519 return value;
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
520 }
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
521
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
522
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
523 /* Convert 16-bit value VALUE which is in little-endian byte-order
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
524 to host byte-order. */
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
525
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
526 static u_int16_t
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
527 le2hs (value)
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
528 u_int16_t value;
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
529 {
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
530 #ifdef WORDS_BIG_ENDIAN
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
531 unsigned char *p = (unsigned char *) &value;
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
532 value = p[0] + (p[1] << 8);
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
533 #endif
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
534 return value;
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
535 }
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
536
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
537
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
538 /* Convert 32-bit value VALUE which is in big-endian byte-order
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
539 to host byte-order. */
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
540
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
541 static u_int32_t
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
542 be2hl (value)
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
543 u_int32_t value;
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
544 {
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
545 #ifndef WORDS_BIG_ENDIAN
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
546 unsigned char *p = (unsigned char *) &value;
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
547 value = p[3] + (p[2] << 8) + (p[1] << 16) + (p[0] << 24);
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
548 #endif
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
549 return value;
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
550 }
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
551
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
552
25722
2be6ced279d3 (Fplay_sound): Remove usused variables.
Gerd Moellmann <gerd@gnu.org>
parents: 25548
diff changeset
553 #if 0 /* Currently not used. */
2be6ced279d3 (Fplay_sound): Remove usused variables.
Gerd Moellmann <gerd@gnu.org>
parents: 25548
diff changeset
554
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
555 /* Convert 16-bit value VALUE which is in big-endian byte-order
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
556 to host byte-order. */
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
557
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
558 static u_int16_t
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
559 be2hs (value)
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
560 u_int16_t value;
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
561 {
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
562 #ifndef WORDS_BIG_ENDIAN
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
563 unsigned char *p = (unsigned char *) &value;
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
564 value = p[1] + (p[0] << 8);
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
565 #endif
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
566 return value;
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
567 }
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
568
25722
2be6ced279d3 (Fplay_sound): Remove usused variables.
Gerd Moellmann <gerd@gnu.org>
parents: 25548
diff changeset
569 #endif /* 0 */
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
570
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
571
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
572 /***********************************************************************
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
573 RIFF-WAVE (*.wav)
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
574 ***********************************************************************/
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
575
27146
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
576 /* Try to initialize sound file S from S->header. S->header
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
577 contains the first MAX_SOUND_HEADER_BYTES number of bytes from the
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
578 sound file. If the file is a WAV-format file, set up interface
27146
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
579 functions in S and convert header fields to host byte-order.
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
580 Value is non-zero if the file is a WAV file. */
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
581
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
582 static int
27146
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
583 wav_init (s)
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
584 struct sound *s;
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
585 {
27146
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
586 struct wav_header *header = (struct wav_header *) s->header;
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
587
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
588 if (s->header_size < sizeof *header
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
589 || bcmp (s->header, "RIFF", 4) != 0)
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
590 return 0;
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
591
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
592 /* WAV files are in little-endian order. Convert the header
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
593 if on a big-endian machine. */
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
594 header->magic = le2hl (header->magic);
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
595 header->length = le2hl (header->length);
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
596 header->chunk_type = le2hl (header->chunk_type);
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
597 header->chunk_format = le2hl (header->chunk_format);
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
598 header->chunk_length = le2hl (header->chunk_length);
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
599 header->format = le2hs (header->format);
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
600 header->channels = le2hs (header->channels);
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
601 header->sample_rate = le2hl (header->sample_rate);
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
602 header->bytes_per_second = le2hl (header->bytes_per_second);
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
603 header->sample_size = le2hs (header->sample_size);
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
604 header->precision = le2hs (header->precision);
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
605 header->chunk_data = le2hl (header->chunk_data);
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
606 header->data_length = le2hl (header->data_length);
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
607
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
608 /* Set up the interface functions for WAV. */
27146
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
609 s->type = RIFF;
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
610 s->play = wav_play;
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
611
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
612 return 1;
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
613 }
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
614
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
615
27146
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
616 /* Play RIFF-WAVE audio file S on sound device SD. */
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
617
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
618 static void
27146
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
619 wav_play (s, sd)
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
620 struct sound *s;
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
621 struct sound_device *sd;
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
622 {
27146
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
623 struct wav_header *header = (struct wav_header *) s->header;
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
624
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
625 /* Let the device choose a suitable device-dependent format
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
626 for the file. */
27146
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
627 sd->choose_format (sd, s);
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
628
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
629 /* Configure the device. */
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
630 sd->sample_size = header->sample_size;
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
631 sd->sample_rate = header->sample_rate;
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
632 sd->bps = header->bytes_per_second;
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
633 sd->channels = header->channels;
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
634 sd->configure (sd);
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
635
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
636 /* Copy sound data to the device. The WAV file specification is
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
637 actually more complex. This simple scheme worked with all WAV
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
638 files I found so far. If someone feels inclined to implement the
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
639 whole RIFF-WAVE spec, please do. */
27146
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
640 if (STRINGP (s->data))
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
641 sd->write (sd, XSTRING (s->data)->data + sizeof *header,
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
642 STRING_BYTES (XSTRING (s->data)) - sizeof *header);
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
643 else
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
644 {
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
645 char *buffer;
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
646 int nbytes;
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
647 int blksize = 2048;
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
648
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
649 buffer = (char *) alloca (blksize);
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
650 lseek (s->fd, sizeof *header, SEEK_SET);
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
651
27146
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
652 while ((nbytes = emacs_read (s->fd, buffer, blksize)) > 0)
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
653 sd->write (sd, buffer, nbytes);
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
654
27146
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
655 if (nbytes < 0)
40364
f7b039994118 (sound_perror): Unblock SIGIO, turn on atimers.
Gerd Moellmann <gerd@gnu.org>
parents: 40123
diff changeset
656 sound_perror ("Error reading sound file");
27146
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
657 }
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
658 }
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
659
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
660
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
661
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
662 /***********************************************************************
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
663 Sun Audio (*.au)
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
664 ***********************************************************************/
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
665
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
666 /* Sun audio file encodings. */
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
667
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
668 enum au_encoding
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
669 {
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
670 AU_ENCODING_ULAW_8 = 1,
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
671 AU_ENCODING_8,
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
672 AU_ENCODING_16,
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
673 AU_ENCODING_24,
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
674 AU_ENCODING_32,
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
675 AU_ENCODING_IEEE32,
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
676 AU_ENCODING_IEEE64,
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
677 AU_COMPRESSED = 23
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
678 };
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
679
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
680
27146
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
681 /* Try to initialize sound file S from S->header. S->header
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
682 contains the first MAX_SOUND_HEADER_BYTES number of bytes from the
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
683 sound file. If the file is a AU-format file, set up interface
27146
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
684 functions in S and convert header fields to host byte-order.
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
685 Value is non-zero if the file is an AU file. */
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
686
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
687 static int
27146
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
688 au_init (s)
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
689 struct sound *s;
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
690 {
27146
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
691 struct au_header *header = (struct au_header *) s->header;
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
692
27146
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
693 if (s->header_size < sizeof *header
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
694 || bcmp (s->header, ".snd", 4) != 0)
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
695 return 0;
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
696
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
697 header->magic_number = be2hl (header->magic_number);
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
698 header->data_offset = be2hl (header->data_offset);
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
699 header->data_size = be2hl (header->data_size);
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
700 header->encoding = be2hl (header->encoding);
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
701 header->sample_rate = be2hl (header->sample_rate);
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
702 header->channels = be2hl (header->channels);
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
703
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
704 /* Set up the interface functions for AU. */
27146
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
705 s->type = SUN_AUDIO;
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
706 s->play = au_play;
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
707
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
708 return 1;
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
709 }
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
710
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
711
27146
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
712 /* Play Sun audio file S on sound device SD. */
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
713
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
714 static void
27146
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
715 au_play (s, sd)
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
716 struct sound *s;
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
717 struct sound_device *sd;
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
718 {
27146
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
719 struct au_header *header = (struct au_header *) s->header;
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
720
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
721 sd->sample_size = 0;
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
722 sd->sample_rate = header->sample_rate;
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
723 sd->bps = 0;
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
724 sd->channels = header->channels;
27146
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
725 sd->choose_format (sd, s);
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
726 sd->configure (sd);
27146
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
727
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
728 if (STRINGP (s->data))
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
729 sd->write (sd, XSTRING (s->data)->data + header->data_offset,
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
730 STRING_BYTES (XSTRING (s->data)) - header->data_offset);
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
731 else
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
732 {
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
733 int blksize = 2048;
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
734 char *buffer;
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
735 int nbytes;
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
736
27146
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
737 /* Seek */
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
738 lseek (s->fd, header->data_offset, SEEK_SET);
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
739
27146
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
740 /* Copy sound data to the device. */
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
741 buffer = (char *) alloca (blksize);
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
742 while ((nbytes = emacs_read (s->fd, buffer, blksize)) > 0)
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
743 sd->write (sd, buffer, nbytes);
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
744
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
745 if (nbytes < 0)
40364
f7b039994118 (sound_perror): Unblock SIGIO, turn on atimers.
Gerd Moellmann <gerd@gnu.org>
parents: 40123
diff changeset
746 sound_perror ("Error reading sound file");
27146
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
747 }
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
748 }
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
749
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
750
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
751
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
752 /***********************************************************************
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
753 Voxware Driver Interface
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
754 ***********************************************************************/
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
755
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
756 /* This driver is available on GNU/Linux, and the free BSDs. FreeBSD
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
757 has a compatible own driver aka Luigi's driver. */
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
758
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
759
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
760 /* Open device SD. If SD->file is non-null, open that device,
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
761 otherwise use a default device name. */
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
762
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
763 static void
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
764 vox_open (sd)
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
765 struct sound_device *sd;
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
766 {
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
767 char *file;
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
768
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
769 /* Open the sound device. Default is /dev/dsp. */
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
770 if (sd->file)
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
771 file = sd->file;
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
772 else
30079
1572612184fc Sound support for NetBSD through "Linux emulation" support:
Ken Raeburn <raeburn@raeburn.org>
parents: 29717
diff changeset
773 file = DEFAULT_SOUND_DEVICE;
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
774
26088
b7aa6ac26872 Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents: 25722
diff changeset
775 sd->fd = emacs_open (file, O_WRONLY, 0);
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
776 if (sd->fd < 0)
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
777 sound_perror (file);
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
778 }
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
779
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
780
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
781 /* Configure device SD from parameters in it. */
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
782
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
783 static void
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
784 vox_configure (sd)
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
785 struct sound_device *sd;
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
786 {
34354
db2901e01b72 (vox_configure): Change order of ioctls. Don't
Gerd Moellmann <gerd@gnu.org>
parents: 34255
diff changeset
787 int val;
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
788
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
789 xassert (sd->fd >= 0);
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
790
38338
c6ff61f9af43 (toplevel): Include <signal.h> and "syssignal.h".
Gerd Moellmann <gerd@gnu.org>
parents: 38297
diff changeset
791 /* On GNU/Linux, it seems that the device driver doesn't like to be
c6ff61f9af43 (toplevel): Include <signal.h> and "syssignal.h".
Gerd Moellmann <gerd@gnu.org>
parents: 38297
diff changeset
792 interrupted by a signal. Block the ones we know to cause
c6ff61f9af43 (toplevel): Include <signal.h> and "syssignal.h".
Gerd Moellmann <gerd@gnu.org>
parents: 38297
diff changeset
793 troubles. */
38215
b9fdde642b13 (vox_configure, vox_close): Turn off atimers
Gerd Moellmann <gerd@gnu.org>
parents: 34354
diff changeset
794 turn_on_atimers (0);
38338
c6ff61f9af43 (toplevel): Include <signal.h> and "syssignal.h".
Gerd Moellmann <gerd@gnu.org>
parents: 38297
diff changeset
795 #ifdef SIGIO
c6ff61f9af43 (toplevel): Include <signal.h> and "syssignal.h".
Gerd Moellmann <gerd@gnu.org>
parents: 38297
diff changeset
796 sigblock (sigmask (SIGIO));
c6ff61f9af43 (toplevel): Include <signal.h> and "syssignal.h".
Gerd Moellmann <gerd@gnu.org>
parents: 38297
diff changeset
797 #endif
38215
b9fdde642b13 (vox_configure, vox_close): Turn off atimers
Gerd Moellmann <gerd@gnu.org>
parents: 34354
diff changeset
798
34354
db2901e01b72 (vox_configure): Change order of ioctls. Don't
Gerd Moellmann <gerd@gnu.org>
parents: 34255
diff changeset
799 val = sd->format;
db2901e01b72 (vox_configure): Change order of ioctls. Don't
Gerd Moellmann <gerd@gnu.org>
parents: 34255
diff changeset
800 if (ioctl (sd->fd, SNDCTL_DSP_SETFMT, &sd->format) < 0
db2901e01b72 (vox_configure): Change order of ioctls. Don't
Gerd Moellmann <gerd@gnu.org>
parents: 34255
diff changeset
801 || val != sd->format)
40364
f7b039994118 (sound_perror): Unblock SIGIO, turn on atimers.
Gerd Moellmann <gerd@gnu.org>
parents: 40123
diff changeset
802 sound_perror ("Could not set sound format");
34354
db2901e01b72 (vox_configure): Change order of ioctls. Don't
Gerd Moellmann <gerd@gnu.org>
parents: 34255
diff changeset
803
db2901e01b72 (vox_configure): Change order of ioctls. Don't
Gerd Moellmann <gerd@gnu.org>
parents: 34255
diff changeset
804 val = sd->channels != 1;
db2901e01b72 (vox_configure): Change order of ioctls. Don't
Gerd Moellmann <gerd@gnu.org>
parents: 34255
diff changeset
805 if (ioctl (sd->fd, SNDCTL_DSP_STEREO, &val) < 0
db2901e01b72 (vox_configure): Change order of ioctls. Don't
Gerd Moellmann <gerd@gnu.org>
parents: 34255
diff changeset
806 || val != (sd->channels != 1))
40364
f7b039994118 (sound_perror): Unblock SIGIO, turn on atimers.
Gerd Moellmann <gerd@gnu.org>
parents: 40123
diff changeset
807 sound_perror ("Could not set stereo/mono");
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
808
34354
db2901e01b72 (vox_configure): Change order of ioctls. Don't
Gerd Moellmann <gerd@gnu.org>
parents: 34255
diff changeset
809 /* I think bps and sampling_rate are the same, but who knows.
db2901e01b72 (vox_configure): Change order of ioctls. Don't
Gerd Moellmann <gerd@gnu.org>
parents: 34255
diff changeset
810 Check this. and use SND_DSP_SPEED for both. */
db2901e01b72 (vox_configure): Change order of ioctls. Don't
Gerd Moellmann <gerd@gnu.org>
parents: 34255
diff changeset
811 if (sd->sample_rate > 0)
db2901e01b72 (vox_configure): Change order of ioctls. Don't
Gerd Moellmann <gerd@gnu.org>
parents: 34255
diff changeset
812 {
db2901e01b72 (vox_configure): Change order of ioctls. Don't
Gerd Moellmann <gerd@gnu.org>
parents: 34255
diff changeset
813 val = sd->sample_rate;
40364
f7b039994118 (sound_perror): Unblock SIGIO, turn on atimers.
Gerd Moellmann <gerd@gnu.org>
parents: 40123
diff changeset
814 if (ioctl (sd->fd, SNDCTL_DSP_SPEED, &sd->sample_rate) < 0)
f7b039994118 (sound_perror): Unblock SIGIO, turn on atimers.
Gerd Moellmann <gerd@gnu.org>
parents: 40123
diff changeset
815 sound_perror ("Could not set sound speed");
f7b039994118 (sound_perror): Unblock SIGIO, turn on atimers.
Gerd Moellmann <gerd@gnu.org>
parents: 40123
diff changeset
816 else if (val != sd->sample_rate)
f7b039994118 (sound_perror): Unblock SIGIO, turn on atimers.
Gerd Moellmann <gerd@gnu.org>
parents: 40123
diff changeset
817 sound_warning ("Could not set sample rate");
34354
db2901e01b72 (vox_configure): Change order of ioctls. Don't
Gerd Moellmann <gerd@gnu.org>
parents: 34255
diff changeset
818 }
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
819
34255
cb2b0d1799db (vox_configure): Set volume for left and right channel.
Gerd Moellmann <gerd@gnu.org>
parents: 31587
diff changeset
820 if (sd->volume > 0)
cb2b0d1799db (vox_configure): Set volume for left and right channel.
Gerd Moellmann <gerd@gnu.org>
parents: 31587
diff changeset
821 {
cb2b0d1799db (vox_configure): Set volume for left and right channel.
Gerd Moellmann <gerd@gnu.org>
parents: 31587
diff changeset
822 int volume = sd->volume & 0xff;
cb2b0d1799db (vox_configure): Set volume for left and right channel.
Gerd Moellmann <gerd@gnu.org>
parents: 31587
diff changeset
823 volume |= volume << 8;
34354
db2901e01b72 (vox_configure): Change order of ioctls. Don't
Gerd Moellmann <gerd@gnu.org>
parents: 34255
diff changeset
824 /* This may fail if there is no mixer. Ignore the failure. */
db2901e01b72 (vox_configure): Change order of ioctls. Don't
Gerd Moellmann <gerd@gnu.org>
parents: 34255
diff changeset
825 ioctl (sd->fd, SOUND_MIXER_WRITE_PCM, &volume);
34255
cb2b0d1799db (vox_configure): Set volume for left and right channel.
Gerd Moellmann <gerd@gnu.org>
parents: 31587
diff changeset
826 }
38215
b9fdde642b13 (vox_configure, vox_close): Turn off atimers
Gerd Moellmann <gerd@gnu.org>
parents: 34354
diff changeset
827
b9fdde642b13 (vox_configure, vox_close): Turn off atimers
Gerd Moellmann <gerd@gnu.org>
parents: 34354
diff changeset
828 turn_on_atimers (1);
38338
c6ff61f9af43 (toplevel): Include <signal.h> and "syssignal.h".
Gerd Moellmann <gerd@gnu.org>
parents: 38297
diff changeset
829 #ifdef SIGIO
c6ff61f9af43 (toplevel): Include <signal.h> and "syssignal.h".
Gerd Moellmann <gerd@gnu.org>
parents: 38297
diff changeset
830 sigunblock (sigmask (SIGIO));
c6ff61f9af43 (toplevel): Include <signal.h> and "syssignal.h".
Gerd Moellmann <gerd@gnu.org>
parents: 38297
diff changeset
831 #endif
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
832 }
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
833
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
834
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
835 /* Close device SD if it is open. */
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
836
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
837 static void
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
838 vox_close (sd)
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
839 struct sound_device *sd;
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
840 {
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
841 if (sd->fd >= 0)
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
842 {
38338
c6ff61f9af43 (toplevel): Include <signal.h> and "syssignal.h".
Gerd Moellmann <gerd@gnu.org>
parents: 38297
diff changeset
843 /* On GNU/Linux, it seems that the device driver doesn't like to
c6ff61f9af43 (toplevel): Include <signal.h> and "syssignal.h".
Gerd Moellmann <gerd@gnu.org>
parents: 38297
diff changeset
844 be interrupted by a signal. Block the ones we know to cause
c6ff61f9af43 (toplevel): Include <signal.h> and "syssignal.h".
Gerd Moellmann <gerd@gnu.org>
parents: 38297
diff changeset
845 troubles. */
c6ff61f9af43 (toplevel): Include <signal.h> and "syssignal.h".
Gerd Moellmann <gerd@gnu.org>
parents: 38297
diff changeset
846 #ifdef SIGIO
c6ff61f9af43 (toplevel): Include <signal.h> and "syssignal.h".
Gerd Moellmann <gerd@gnu.org>
parents: 38297
diff changeset
847 sigblock (sigmask (SIGIO));
c6ff61f9af43 (toplevel): Include <signal.h> and "syssignal.h".
Gerd Moellmann <gerd@gnu.org>
parents: 38297
diff changeset
848 #endif
38215
b9fdde642b13 (vox_configure, vox_close): Turn off atimers
Gerd Moellmann <gerd@gnu.org>
parents: 34354
diff changeset
849 turn_on_atimers (0);
38338
c6ff61f9af43 (toplevel): Include <signal.h> and "syssignal.h".
Gerd Moellmann <gerd@gnu.org>
parents: 38297
diff changeset
850
c6ff61f9af43 (toplevel): Include <signal.h> and "syssignal.h".
Gerd Moellmann <gerd@gnu.org>
parents: 38297
diff changeset
851 /* Flush sound data, and reset the device. */
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
852 ioctl (sd->fd, SNDCTL_DSP_SYNC, NULL);
38338
c6ff61f9af43 (toplevel): Include <signal.h> and "syssignal.h".
Gerd Moellmann <gerd@gnu.org>
parents: 38297
diff changeset
853
38215
b9fdde642b13 (vox_configure, vox_close): Turn off atimers
Gerd Moellmann <gerd@gnu.org>
parents: 34354
diff changeset
854 turn_on_atimers (1);
38338
c6ff61f9af43 (toplevel): Include <signal.h> and "syssignal.h".
Gerd Moellmann <gerd@gnu.org>
parents: 38297
diff changeset
855 #ifdef SIGIO
c6ff61f9af43 (toplevel): Include <signal.h> and "syssignal.h".
Gerd Moellmann <gerd@gnu.org>
parents: 38297
diff changeset
856 sigunblock (sigmask (SIGIO));
c6ff61f9af43 (toplevel): Include <signal.h> and "syssignal.h".
Gerd Moellmann <gerd@gnu.org>
parents: 38297
diff changeset
857 #endif
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
858
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
859 /* Close the device. */
26088
b7aa6ac26872 Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents: 25722
diff changeset
860 emacs_close (sd->fd);
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
861 sd->fd = -1;
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
862 }
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
863 }
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
864
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
865
27146
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
866 /* Choose device-dependent format for device SD from sound file S. */
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
867
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
868 static void
27146
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
869 vox_choose_format (sd, s)
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
870 struct sound_device *sd;
27146
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
871 struct sound *s;
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
872 {
27146
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
873 if (s->type == RIFF)
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
874 {
27146
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
875 struct wav_header *h = (struct wav_header *) s->header;
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
876 if (h->precision == 8)
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
877 sd->format = AFMT_U8;
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
878 else if (h->precision == 16)
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
879 sd->format = AFMT_S16_LE;
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
880 else
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
881 error ("Unsupported WAV file format");
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
882 }
27146
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
883 else if (s->type == SUN_AUDIO)
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
884 {
27146
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
885 struct au_header *header = (struct au_header *) s->header;
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
886 switch (header->encoding)
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
887 {
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
888 case AU_ENCODING_ULAW_8:
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
889 case AU_ENCODING_IEEE32:
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
890 case AU_ENCODING_IEEE64:
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
891 sd->format = AFMT_MU_LAW;
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
892 break;
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
893
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
894 case AU_ENCODING_8:
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
895 case AU_ENCODING_16:
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
896 case AU_ENCODING_24:
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
897 case AU_ENCODING_32:
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
898 sd->format = AFMT_S16_LE;
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
899 break;
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
900
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
901 default:
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
902 error ("Unsupported AU file format");
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
903 }
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
904 }
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
905 else
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
906 abort ();
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
907 }
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
908
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
909
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
910 /* Initialize device SD. Set up the interface functions in the device
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
911 structure. */
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
912
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
913 static void
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
914 vox_init (sd)
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
915 struct sound_device *sd;
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
916 {
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
917 sd->fd = -1;
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
918 sd->open = vox_open;
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
919 sd->close = vox_close;
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
920 sd->configure = vox_configure;
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
921 sd->choose_format = vox_choose_format;
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
922 sd->write = vox_write;
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
923 }
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
924
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
925
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
926 /* Write NBYTES bytes from BUFFER to device SD. */
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
927
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
928 static void
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
929 vox_write (sd, buffer, nbytes)
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
930 struct sound_device *sd;
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
931 char *buffer;
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
932 int nbytes;
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
933 {
26088
b7aa6ac26872 Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents: 25722
diff changeset
934 int nwritten = emacs_write (sd->fd, buffer, nbytes);
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
935 if (nwritten < 0)
40364
f7b039994118 (sound_perror): Unblock SIGIO, turn on atimers.
Gerd Moellmann <gerd@gnu.org>
parents: 40123
diff changeset
936 sound_perror ("Error writing to sound device");
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
937 }
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
938
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
939
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
940
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
941 /***********************************************************************
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
942 Initialization
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
943 ***********************************************************************/
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
944
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
945 void
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
946 syms_of_sound ()
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
947 {
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
948 QCdevice = intern (":device");
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
949 staticpro (&QCdevice);
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
950 QCvolume = intern (":volume");
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
951 staticpro (&QCvolume);
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
952 Qsound = intern ("sound");
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
953 staticpro (&Qsound);
25548
df6548ca33fd (Qplay_sound_functions): Replaces Qplay_sound_hook.
Gerd Moellmann <gerd@gnu.org>
parents: 25003
diff changeset
954 Qplay_sound_functions = intern ("play-sound-functions");
df6548ca33fd (Qplay_sound_functions): Replaces Qplay_sound_hook.
Gerd Moellmann <gerd@gnu.org>
parents: 25003
diff changeset
955 staticpro (&Qplay_sound_functions);
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
956
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
957 defsubr (&Splay_sound);
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
958 }
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
959
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
960
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
961 void
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
962 init_sound ()
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
963 {
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
964 }
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
965
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
966 #endif /* HAVE_SOUND */