Mercurial > pidgin
annotate src/sound.c @ 2658:3b1100c527f9
[gaim-migrate @ 2671]
Oops. Silly me.
committer: Tailor Script <tailor@pidgin.im>
author | Rob Flynn <gaim@robflynn.com> |
---|---|
date | Thu, 01 Nov 2001 22:38:35 +0000 |
parents | 61952dde7677 |
children | ab2ca2770d2e |
rev | line source |
---|---|
1 | 1 /* |
2 * gaim | |
3 * | |
4 * Copyright (C) 1998-1999, Mark Spencer <markster@marko.net> | |
5 * | |
6 * This program is free software; you can redistribute it and/or modify | |
7 * it under the terms of the GNU General Public License as published by | |
8 * the Free Software Foundation; either version 2 of the License, or | |
9 * (at your option) any later version. | |
10 * | |
11 * This program is distributed in the hope that it will be useful, | |
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 * GNU General Public License for more details. | |
15 * | |
16 * You should have received a copy of the GNU General Public License | |
17 * along with this program; if not, write to the Free Software | |
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
19 * | |
20 */ | |
21 | |
349
b402a23f35df
[gaim-migrate @ 359]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
22 #ifdef HAVE_CONFIG_H |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2048
diff
changeset
|
23 #include <config.h> |
349
b402a23f35df
[gaim-migrate @ 359]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
24 #endif |
1 | 25 #include <stdio.h> |
1057
d50d3abb9eb7
[gaim-migrate @ 1067]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1006
diff
changeset
|
26 #include <stdlib.h> |
1 | 27 #include <string.h> |
28 #include <sys/time.h> | |
29 #include <unistd.h> | |
30 #include <fcntl.h> | |
31 #include <sys/wait.h> | |
63 | 32 #include <unistd.h> |
33 #include <sys/types.h> | |
34 #include <sys/stat.h> | |
1 | 35 |
36 #ifdef ESD_SOUND | |
37 #include <esd.h> | |
38 #endif | |
39 | |
2179
64d8ef561763
[gaim-migrate @ 2189]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2158
diff
changeset
|
40 #ifdef ARTSC_SOUND |
64d8ef561763
[gaim-migrate @ 2189]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2158
diff
changeset
|
41 #include <artsc.h> |
64d8ef561763
[gaim-migrate @ 2189]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2158
diff
changeset
|
42 #endif |
64d8ef561763
[gaim-migrate @ 2189]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2158
diff
changeset
|
43 |
1 | 44 #ifdef NAS_SOUND |
45 #include <audio/audiolib.h> | |
46 #endif | |
47 | |
48 #include "gaim.h" | |
49 #include "sounds/BuddyArrive.h" | |
50 #include "sounds/BuddyLeave.h" | |
51 #include "sounds/Send.h" | |
52 #include "sounds/Receive.h" | |
1694 | 53 #include "sounds/RedAlert.h" |
1 | 54 |
655
6ba20a0089d8
[gaim-migrate @ 665]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
606
diff
changeset
|
55 static int check_dev(char *dev) |
6ba20a0089d8
[gaim-migrate @ 665]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
606
diff
changeset
|
56 { |
6ba20a0089d8
[gaim-migrate @ 665]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
606
diff
changeset
|
57 struct stat stat_buf; |
6ba20a0089d8
[gaim-migrate @ 665]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
606
diff
changeset
|
58 uid_t user = getuid(); |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1235
diff
changeset
|
59 gid_t group = getgid(), other_groups[32]; |
899
88d1edcd7cd6
[gaim-migrate @ 909]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
778
diff
changeset
|
60 int i, numgroups; |
88d1edcd7cd6
[gaim-migrate @ 909]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
778
diff
changeset
|
61 |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1235
diff
changeset
|
62 if ((numgroups = getgroups(32, other_groups)) == -1) |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1235
diff
changeset
|
63 return 0; |
655
6ba20a0089d8
[gaim-migrate @ 665]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
606
diff
changeset
|
64 if (stat(dev, &stat_buf)) |
6ba20a0089d8
[gaim-migrate @ 665]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
606
diff
changeset
|
65 return 0; |
6ba20a0089d8
[gaim-migrate @ 665]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
606
diff
changeset
|
66 if (user == stat_buf.st_uid && stat_buf.st_mode & S_IWUSR) |
6ba20a0089d8
[gaim-migrate @ 665]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
606
diff
changeset
|
67 return 1; |
899
88d1edcd7cd6
[gaim-migrate @ 909]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
778
diff
changeset
|
68 if (stat_buf.st_mode & S_IWGRP) { |
88d1edcd7cd6
[gaim-migrate @ 909]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
778
diff
changeset
|
69 if (group == stat_buf.st_gid) |
88d1edcd7cd6
[gaim-migrate @ 909]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
778
diff
changeset
|
70 return 1; |
88d1edcd7cd6
[gaim-migrate @ 909]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
778
diff
changeset
|
71 for (i = 0; i < numgroups; i++) |
88d1edcd7cd6
[gaim-migrate @ 909]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
778
diff
changeset
|
72 if (other_groups[i] == stat_buf.st_gid) |
88d1edcd7cd6
[gaim-migrate @ 909]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
778
diff
changeset
|
73 return 1; |
88d1edcd7cd6
[gaim-migrate @ 909]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
778
diff
changeset
|
74 } |
655
6ba20a0089d8
[gaim-migrate @ 665]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
606
diff
changeset
|
75 if (stat_buf.st_mode & S_IWOTH) |
6ba20a0089d8
[gaim-migrate @ 665]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
606
diff
changeset
|
76 return 1; |
6ba20a0089d8
[gaim-migrate @ 665]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
606
diff
changeset
|
77 return 0; |
6ba20a0089d8
[gaim-migrate @ 665]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
606
diff
changeset
|
78 } |
6ba20a0089d8
[gaim-migrate @ 665]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
606
diff
changeset
|
79 |
1 | 80 |
2048
3366311426df
[gaim-migrate @ 2058]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1805
diff
changeset
|
81 static void play_audio(unsigned char *data, int size) |
1 | 82 { |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1235
diff
changeset
|
83 int fd; |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1235
diff
changeset
|
84 |
2467
cd81f1f2c896
[gaim-migrate @ 2480]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2372
diff
changeset
|
85 fd = open("/dev/audio", O_WRONLY | O_EXCL | O_NDELAY); |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1235
diff
changeset
|
86 if (fd < 0) |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1235
diff
changeset
|
87 return; |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1235
diff
changeset
|
88 write(fd, data, size); |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1235
diff
changeset
|
89 close(fd); |
1 | 90 } |
91 | |
1006
0a4d0ed65e17
[gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
899
diff
changeset
|
92 static void play_audio_file(char *file) |
0a4d0ed65e17
[gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
899
diff
changeset
|
93 { |
0a4d0ed65e17
[gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
899
diff
changeset
|
94 /* here we can assume that we can write to /dev/audio */ |
0a4d0ed65e17
[gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
899
diff
changeset
|
95 char *buf; |
0a4d0ed65e17
[gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
899
diff
changeset
|
96 struct stat info; |
0a4d0ed65e17
[gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
899
diff
changeset
|
97 int fd = open(file, O_RDONLY); |
0a4d0ed65e17
[gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
899
diff
changeset
|
98 if (fd <= 0) { |
0a4d0ed65e17
[gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
899
diff
changeset
|
99 return; |
0a4d0ed65e17
[gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
899
diff
changeset
|
100 } |
0a4d0ed65e17
[gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
899
diff
changeset
|
101 fstat(fd, &info); |
1109
c73736fa0b7c
[gaim-migrate @ 1119]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1057
diff
changeset
|
102 if (info.st_size < 24) |
c73736fa0b7c
[gaim-migrate @ 1119]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1057
diff
changeset
|
103 return; |
1006
0a4d0ed65e17
[gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
899
diff
changeset
|
104 buf = malloc(info.st_size + 1); |
0a4d0ed65e17
[gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
899
diff
changeset
|
105 read(fd, buf, 24); |
0a4d0ed65e17
[gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
899
diff
changeset
|
106 read(fd, buf, info.st_size - 24); |
0a4d0ed65e17
[gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
899
diff
changeset
|
107 close(fd); |
0a4d0ed65e17
[gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
899
diff
changeset
|
108 |
2467
cd81f1f2c896
[gaim-migrate @ 2480]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2372
diff
changeset
|
109 fd = open("/dev/audio", O_WRONLY | O_EXCL | O_NDELAY); |
1109
c73736fa0b7c
[gaim-migrate @ 1119]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1057
diff
changeset
|
110 if (fd < 0) { |
c73736fa0b7c
[gaim-migrate @ 1119]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1057
diff
changeset
|
111 free(buf); |
1006
0a4d0ed65e17
[gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
899
diff
changeset
|
112 return; |
1109
c73736fa0b7c
[gaim-migrate @ 1119]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1057
diff
changeset
|
113 } |
1006
0a4d0ed65e17
[gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
899
diff
changeset
|
114 write(fd, buf, info.st_size - 24); |
0a4d0ed65e17
[gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
899
diff
changeset
|
115 free(buf); |
0a4d0ed65e17
[gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
899
diff
changeset
|
116 close(fd); |
0a4d0ed65e17
[gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
899
diff
changeset
|
117 } |
0a4d0ed65e17
[gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
899
diff
changeset
|
118 |
1 | 119 static int can_play_audio() |
120 { | |
655
6ba20a0089d8
[gaim-migrate @ 665]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
606
diff
changeset
|
121 return check_dev("/dev/audio"); |
1 | 122 } |
123 | |
124 | |
2179
64d8ef561763
[gaim-migrate @ 2189]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2158
diff
changeset
|
125 #if defined(ESD_SOUND) || defined(ARTSC_SOUND) |
64d8ef561763
[gaim-migrate @ 2189]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2158
diff
changeset
|
126 |
1 | 127 /* |
128 ** This routine converts from ulaw to 16 bit linear. | |
129 ** | |
130 ** Craig Reese: IDA/Supercomputing Research Center | |
131 ** 29 September 1989 | |
132 ** | |
133 ** References: | |
134 ** 1) CCITT Recommendation G.711 (very difficult to follow) | |
135 ** 2) MIL-STD-188-113,"Interoperability and Performance Standards | |
136 ** for Analog-to_Digital Conversion Techniques," | |
137 ** 17 February 1987 | |
138 ** | |
139 ** Input: 8 bit ulaw sample | |
140 ** Output: signed 16 bit linear sample | |
141 ** Z-note -- this is from libaudiofile. Thanks guys! | |
142 */ | |
143 | |
2158
9b7cb09e2c06
[gaim-migrate @ 2168]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2090
diff
changeset
|
144 static int _af_ulaw2linear(unsigned char ulawbyte) |
1 | 145 { |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1235
diff
changeset
|
146 static int exp_lut[8] = { 0, 132, 396, 924, 1980, 4092, 8316, 16764 }; |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1235
diff
changeset
|
147 int sign, exponent, mantissa, sample; |
1 | 148 |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1235
diff
changeset
|
149 ulawbyte = ~ulawbyte; |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1235
diff
changeset
|
150 sign = (ulawbyte & 0x80); |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1235
diff
changeset
|
151 exponent = (ulawbyte >> 4) & 0x07; |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1235
diff
changeset
|
152 mantissa = ulawbyte & 0x0F; |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1235
diff
changeset
|
153 sample = exp_lut[exponent] + (mantissa << (exponent + 3)); |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1235
diff
changeset
|
154 if (sign != 0) |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1235
diff
changeset
|
155 sample = -sample; |
1 | 156 |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1235
diff
changeset
|
157 return (sample); |
1 | 158 } |
159 | |
2179
64d8ef561763
[gaim-migrate @ 2189]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2158
diff
changeset
|
160 #endif |
64d8ef561763
[gaim-migrate @ 2189]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2158
diff
changeset
|
161 |
64d8ef561763
[gaim-migrate @ 2189]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2158
diff
changeset
|
162 #ifdef ESD_SOUND |
1 | 163 |
354
2b91e42bff70
[gaim-migrate @ 364]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
349
diff
changeset
|
164 int esd_fd; |
1 | 165 |
166 static int play_esd(unsigned char *data, int size) | |
167 { | |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1235
diff
changeset
|
168 int i; |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1235
diff
changeset
|
169 guint16 *lineardata; |
1 | 170 |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1235
diff
changeset
|
171 lineardata = g_malloc(size * 2); |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1235
diff
changeset
|
172 |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1235
diff
changeset
|
173 for (i = 0; i < size; i++) |
1 | 174 lineardata[i] = _af_ulaw2linear(data[i]); |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1235
diff
changeset
|
175 |
354
2b91e42bff70
[gaim-migrate @ 364]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
349
diff
changeset
|
176 write(esd_fd, lineardata, size * 2); |
1 | 177 |
354
2b91e42bff70
[gaim-migrate @ 364]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
349
diff
changeset
|
178 close(esd_fd); |
1 | 179 g_free(lineardata); |
180 | |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1235
diff
changeset
|
181 return 1; |
1 | 182 |
183 } | |
184 | |
185 static int can_play_esd() | |
186 { | |
354
2b91e42bff70
[gaim-migrate @ 364]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
349
diff
changeset
|
187 esd_format_t format = ESD_BITS16 | ESD_STREAM | ESD_PLAY | ESD_MONO; |
655
6ba20a0089d8
[gaim-migrate @ 665]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
606
diff
changeset
|
188 |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1235
diff
changeset
|
189 esd_fd = esd_play_stream(format, 8012, NULL, "gaim"); |
354
2b91e42bff70
[gaim-migrate @ 364]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
349
diff
changeset
|
190 |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1235
diff
changeset
|
191 if (esd_fd < 0) { |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1235
diff
changeset
|
192 return 0; |
354
2b91e42bff70
[gaim-migrate @ 364]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
349
diff
changeset
|
193 } |
2b91e42bff70
[gaim-migrate @ 364]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
349
diff
changeset
|
194 |
2b91e42bff70
[gaim-migrate @ 364]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
349
diff
changeset
|
195 return 1; |
1 | 196 } |
197 | |
198 #endif | |
199 | |
2179
64d8ef561763
[gaim-migrate @ 2189]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2158
diff
changeset
|
200 #ifdef ARTSC_SOUND |
64d8ef561763
[gaim-migrate @ 2189]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2158
diff
changeset
|
201 |
64d8ef561763
[gaim-migrate @ 2189]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2158
diff
changeset
|
202 static int play_artsc(unsigned char *data, int size) |
64d8ef561763
[gaim-migrate @ 2189]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2158
diff
changeset
|
203 { |
64d8ef561763
[gaim-migrate @ 2189]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2158
diff
changeset
|
204 arts_stream_t stream; |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2370
diff
changeset
|
205 guint16 *lineardata; |
2179
64d8ef561763
[gaim-migrate @ 2189]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2158
diff
changeset
|
206 int result = 1; |
64d8ef561763
[gaim-migrate @ 2189]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2158
diff
changeset
|
207 int error; |
64d8ef561763
[gaim-migrate @ 2189]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2158
diff
changeset
|
208 int i; |
64d8ef561763
[gaim-migrate @ 2189]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2158
diff
changeset
|
209 |
64d8ef561763
[gaim-migrate @ 2189]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2158
diff
changeset
|
210 lineardata = g_malloc(size * 2); |
64d8ef561763
[gaim-migrate @ 2189]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2158
diff
changeset
|
211 |
64d8ef561763
[gaim-migrate @ 2189]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2158
diff
changeset
|
212 for (i = 0; i < size; i++) { |
64d8ef561763
[gaim-migrate @ 2189]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2158
diff
changeset
|
213 lineardata[i] = _af_ulaw2linear(data[i]); |
64d8ef561763
[gaim-migrate @ 2189]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2158
diff
changeset
|
214 } |
64d8ef561763
[gaim-migrate @ 2189]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2158
diff
changeset
|
215 |
64d8ef561763
[gaim-migrate @ 2189]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2158
diff
changeset
|
216 stream = arts_play_stream(8012, 16, 1, "gaim"); |
64d8ef561763
[gaim-migrate @ 2189]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2158
diff
changeset
|
217 |
64d8ef561763
[gaim-migrate @ 2189]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2158
diff
changeset
|
218 error = arts_write(stream, lineardata, size); |
64d8ef561763
[gaim-migrate @ 2189]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2158
diff
changeset
|
219 if (error < 0) { |
64d8ef561763
[gaim-migrate @ 2189]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2158
diff
changeset
|
220 result = 0; |
64d8ef561763
[gaim-migrate @ 2189]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2158
diff
changeset
|
221 } |
64d8ef561763
[gaim-migrate @ 2189]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2158
diff
changeset
|
222 |
64d8ef561763
[gaim-migrate @ 2189]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2158
diff
changeset
|
223 arts_close_stream(stream); |
64d8ef561763
[gaim-migrate @ 2189]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2158
diff
changeset
|
224 |
64d8ef561763
[gaim-migrate @ 2189]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2158
diff
changeset
|
225 g_free(lineardata); |
64d8ef561763
[gaim-migrate @ 2189]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2158
diff
changeset
|
226 |
64d8ef561763
[gaim-migrate @ 2189]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2158
diff
changeset
|
227 arts_free(); |
64d8ef561763
[gaim-migrate @ 2189]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2158
diff
changeset
|
228 |
64d8ef561763
[gaim-migrate @ 2189]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2158
diff
changeset
|
229 return result; |
64d8ef561763
[gaim-migrate @ 2189]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2158
diff
changeset
|
230 } |
64d8ef561763
[gaim-migrate @ 2189]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2158
diff
changeset
|
231 |
64d8ef561763
[gaim-migrate @ 2189]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2158
diff
changeset
|
232 static int can_play_artsc() |
64d8ef561763
[gaim-migrate @ 2189]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2158
diff
changeset
|
233 { |
64d8ef561763
[gaim-migrate @ 2189]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2158
diff
changeset
|
234 int error; |
64d8ef561763
[gaim-migrate @ 2189]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2158
diff
changeset
|
235 |
2183
94ee8eacb6f8
[gaim-migrate @ 2193]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2179
diff
changeset
|
236 error = arts_init(); |
2179
64d8ef561763
[gaim-migrate @ 2189]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2158
diff
changeset
|
237 if (error < 0) |
64d8ef561763
[gaim-migrate @ 2189]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2158
diff
changeset
|
238 return 0; |
64d8ef561763
[gaim-migrate @ 2189]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2158
diff
changeset
|
239 |
64d8ef561763
[gaim-migrate @ 2189]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2158
diff
changeset
|
240 return 1; |
64d8ef561763
[gaim-migrate @ 2189]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2158
diff
changeset
|
241 } |
64d8ef561763
[gaim-migrate @ 2189]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2158
diff
changeset
|
242 |
2186
08781af8e3a9
[gaim-migrate @ 2196]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2183
diff
changeset
|
243 static int artsc_play_file(char *file) |
2179
64d8ef561763
[gaim-migrate @ 2189]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2158
diff
changeset
|
244 { |
64d8ef561763
[gaim-migrate @ 2189]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2158
diff
changeset
|
245 struct stat stat_buf; |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2370
diff
changeset
|
246 unsigned char *buf = NULL; |
2179
64d8ef561763
[gaim-migrate @ 2189]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2158
diff
changeset
|
247 int result = 0; |
64d8ef561763
[gaim-migrate @ 2189]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2158
diff
changeset
|
248 int fd = -1; |
64d8ef561763
[gaim-migrate @ 2189]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2158
diff
changeset
|
249 |
64d8ef561763
[gaim-migrate @ 2189]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2158
diff
changeset
|
250 fd = open(file, O_RDONLY); |
64d8ef561763
[gaim-migrate @ 2189]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2158
diff
changeset
|
251 if (fd < 0) |
64d8ef561763
[gaim-migrate @ 2189]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2158
diff
changeset
|
252 goto out; |
64d8ef561763
[gaim-migrate @ 2189]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2158
diff
changeset
|
253 |
64d8ef561763
[gaim-migrate @ 2189]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2158
diff
changeset
|
254 if (!can_play_artsc()) |
64d8ef561763
[gaim-migrate @ 2189]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2158
diff
changeset
|
255 goto out; |
64d8ef561763
[gaim-migrate @ 2189]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2158
diff
changeset
|
256 |
64d8ef561763
[gaim-migrate @ 2189]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2158
diff
changeset
|
257 if (fstat(fd, &stat_buf)) |
64d8ef561763
[gaim-migrate @ 2189]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2158
diff
changeset
|
258 goto out; |
64d8ef561763
[gaim-migrate @ 2189]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2158
diff
changeset
|
259 |
64d8ef561763
[gaim-migrate @ 2189]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2158
diff
changeset
|
260 if (!stat_buf.st_size) |
64d8ef561763
[gaim-migrate @ 2189]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2158
diff
changeset
|
261 goto out; |
64d8ef561763
[gaim-migrate @ 2189]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2158
diff
changeset
|
262 |
64d8ef561763
[gaim-migrate @ 2189]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2158
diff
changeset
|
263 buf = g_malloc(stat_buf.st_size); |
64d8ef561763
[gaim-migrate @ 2189]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2158
diff
changeset
|
264 if (!buf) |
64d8ef561763
[gaim-migrate @ 2189]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2158
diff
changeset
|
265 goto out; |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2370
diff
changeset
|
266 |
2179
64d8ef561763
[gaim-migrate @ 2189]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2158
diff
changeset
|
267 if (read(fd, buf, stat_buf.st_size) < 0) |
64d8ef561763
[gaim-migrate @ 2189]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2158
diff
changeset
|
268 goto out; |
64d8ef561763
[gaim-migrate @ 2189]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2158
diff
changeset
|
269 |
64d8ef561763
[gaim-migrate @ 2189]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2158
diff
changeset
|
270 result = play_artsc(buf, stat_buf.st_size); |
64d8ef561763
[gaim-migrate @ 2189]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2158
diff
changeset
|
271 |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2370
diff
changeset
|
272 out: |
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2370
diff
changeset
|
273 if (buf) |
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2370
diff
changeset
|
274 g_free(buf); |
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2370
diff
changeset
|
275 if (fd != -1) |
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2370
diff
changeset
|
276 close(fd); |
2179
64d8ef561763
[gaim-migrate @ 2189]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2158
diff
changeset
|
277 return result; |
64d8ef561763
[gaim-migrate @ 2189]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2158
diff
changeset
|
278 } |
64d8ef561763
[gaim-migrate @ 2189]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2158
diff
changeset
|
279 |
64d8ef561763
[gaim-migrate @ 2189]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2158
diff
changeset
|
280 #endif /* ARTSC_SOUND */ |
64d8ef561763
[gaim-migrate @ 2189]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2158
diff
changeset
|
281 |
1 | 282 #ifdef NAS_SOUND |
283 | |
284 char nas_server[] = "localhost"; | |
285 AuServer *nas_serv = NULL; | |
286 | |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1235
diff
changeset
|
287 static AuBool NasEventHandler(AuServer * aud, AuEvent * ev, AuEventHandlerRec * handler) |
1 | 288 { |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1235
diff
changeset
|
289 AuElementNotifyEvent *event = (AuElementNotifyEvent *) ev; |
1 | 290 |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1235
diff
changeset
|
291 if (ev->type == AuEventTypeElementNotify) { |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1235
diff
changeset
|
292 switch (event->kind) { |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1235
diff
changeset
|
293 case AuElementNotifyKindState: |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1235
diff
changeset
|
294 switch (event->cur_state) { |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1235
diff
changeset
|
295 case AuStateStop: |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1235
diff
changeset
|
296 _exit(0); |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1235
diff
changeset
|
297 } |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1235
diff
changeset
|
298 break; |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1235
diff
changeset
|
299 } |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1235
diff
changeset
|
300 } |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1235
diff
changeset
|
301 return AuTrue; |
1 | 302 } |
303 | |
304 | |
305 static int play_nas(unsigned char *data, int size) | |
306 { | |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1235
diff
changeset
|
307 AuDeviceID device = AuNone; |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1235
diff
changeset
|
308 AuFlowID flow; |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1235
diff
changeset
|
309 AuElement elements[3]; |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1235
diff
changeset
|
310 int i, n, w; |
1 | 311 |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1235
diff
changeset
|
312 /* look for an output device */ |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1235
diff
changeset
|
313 for (i = 0; i < AuServerNumDevices(nas_serv); i++) { |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1235
diff
changeset
|
314 if ((AuDeviceKind(AuServerDevice(nas_serv, i)) == |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1235
diff
changeset
|
315 AuComponentKindPhysicalOutput) && |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1235
diff
changeset
|
316 AuDeviceNumTracks(AuServerDevice(nas_serv, i)) == 1) { |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1235
diff
changeset
|
317 device = AuDeviceIdentifier(AuServerDevice(nas_serv, i)); |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1235
diff
changeset
|
318 break; |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1235
diff
changeset
|
319 } |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1235
diff
changeset
|
320 } |
1 | 321 |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1235
diff
changeset
|
322 if (device == AuNone) |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1235
diff
changeset
|
323 return 0; |
1 | 324 |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1235
diff
changeset
|
325 if (!(flow = AuCreateFlow(nas_serv, NULL))) |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1235
diff
changeset
|
326 return 0; |
1 | 327 |
328 | |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1235
diff
changeset
|
329 AuMakeElementImportClient(&elements[0], 8012, AuFormatULAW8, 1, AuTrue, size, size / 2, 0, NULL); |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1235
diff
changeset
|
330 AuMakeElementExportDevice(&elements[1], 0, device, 8012, AuUnlimitedSamples, 0, NULL); |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1235
diff
changeset
|
331 AuSetElements(nas_serv, flow, AuTrue, 2, elements, NULL); |
1 | 332 |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1235
diff
changeset
|
333 AuStartFlow(nas_serv, flow, NULL); |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1235
diff
changeset
|
334 |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1235
diff
changeset
|
335 AuWriteElement(nas_serv, flow, 0, size, data, AuTrue, NULL); |
1 | 336 |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1235
diff
changeset
|
337 AuRegisterEventHandler(nas_serv, AuEventHandlerIDMask, 0, flow, NasEventHandler, NULL); |
1 | 338 |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1235
diff
changeset
|
339 while (1) { |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1235
diff
changeset
|
340 AuHandleEvents(nas_serv); |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1235
diff
changeset
|
341 } |
1 | 342 |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1235
diff
changeset
|
343 return 1; |
1 | 344 } |
345 | |
346 static int can_play_nas() | |
347 { | |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1235
diff
changeset
|
348 if ((nas_serv = AuOpenServer(NULL, 0, NULL, 0, NULL, NULL))) |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1235
diff
changeset
|
349 return 1; |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1235
diff
changeset
|
350 return 0; |
1 | 351 } |
352 | |
1109
c73736fa0b7c
[gaim-migrate @ 1119]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1057
diff
changeset
|
353 static int play_nas_file(char *file) |
c73736fa0b7c
[gaim-migrate @ 1119]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1057
diff
changeset
|
354 { |
c73736fa0b7c
[gaim-migrate @ 1119]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1057
diff
changeset
|
355 struct stat stat_buf; |
c73736fa0b7c
[gaim-migrate @ 1119]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1057
diff
changeset
|
356 char *buf; |
c73736fa0b7c
[gaim-migrate @ 1119]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1057
diff
changeset
|
357 int ret; |
c73736fa0b7c
[gaim-migrate @ 1119]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1057
diff
changeset
|
358 int fd = open(file, O_RDONLY); |
c73736fa0b7c
[gaim-migrate @ 1119]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1057
diff
changeset
|
359 if (fd <= 0) |
c73736fa0b7c
[gaim-migrate @ 1119]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1057
diff
changeset
|
360 return 0; |
c73736fa0b7c
[gaim-migrate @ 1119]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1057
diff
changeset
|
361 |
c73736fa0b7c
[gaim-migrate @ 1119]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1057
diff
changeset
|
362 if (!can_play_nas()) |
c73736fa0b7c
[gaim-migrate @ 1119]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1057
diff
changeset
|
363 return 0; |
c73736fa0b7c
[gaim-migrate @ 1119]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1057
diff
changeset
|
364 |
c73736fa0b7c
[gaim-migrate @ 1119]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1057
diff
changeset
|
365 if (stat(file, &stat_buf)) |
c73736fa0b7c
[gaim-migrate @ 1119]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1057
diff
changeset
|
366 return 0; |
c73736fa0b7c
[gaim-migrate @ 1119]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1057
diff
changeset
|
367 |
c73736fa0b7c
[gaim-migrate @ 1119]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1057
diff
changeset
|
368 if (!stat_buf.st_size) |
c73736fa0b7c
[gaim-migrate @ 1119]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1057
diff
changeset
|
369 return 0; |
c73736fa0b7c
[gaim-migrate @ 1119]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1057
diff
changeset
|
370 |
c73736fa0b7c
[gaim-migrate @ 1119]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1057
diff
changeset
|
371 buf = malloc(stat_buf.st_size); |
c73736fa0b7c
[gaim-migrate @ 1119]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1057
diff
changeset
|
372 read(fd, buf, stat_buf.st_size); |
c73736fa0b7c
[gaim-migrate @ 1119]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1057
diff
changeset
|
373 ret = play_nas(buf, stat_buf.st_size); |
c73736fa0b7c
[gaim-migrate @ 1119]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1057
diff
changeset
|
374 free(buf); |
c73736fa0b7c
[gaim-migrate @ 1119]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1057
diff
changeset
|
375 return ret; |
c73736fa0b7c
[gaim-migrate @ 1119]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1057
diff
changeset
|
376 } |
c73736fa0b7c
[gaim-migrate @ 1119]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1057
diff
changeset
|
377 |
1 | 378 #endif |
379 | |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1235
diff
changeset
|
380 void play_file(char *filename) |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1235
diff
changeset
|
381 { |
1006
0a4d0ed65e17
[gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
899
diff
changeset
|
382 int pid; |
0a4d0ed65e17
[gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
899
diff
changeset
|
383 |
0a4d0ed65e17
[gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
899
diff
changeset
|
384 #ifdef _WIN32 |
0a4d0ed65e17
[gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
899
diff
changeset
|
385 return; |
0a4d0ed65e17
[gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
899
diff
changeset
|
386 #endif |
0a4d0ed65e17
[gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
899
diff
changeset
|
387 |
0a4d0ed65e17
[gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
899
diff
changeset
|
388 pid = fork(); |
0a4d0ed65e17
[gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
899
diff
changeset
|
389 |
0a4d0ed65e17
[gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
899
diff
changeset
|
390 if (pid < 0) |
0a4d0ed65e17
[gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
899
diff
changeset
|
391 return; |
0a4d0ed65e17
[gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
899
diff
changeset
|
392 else if (pid == 0) { |
2601
61952dde7677
[gaim-migrate @ 2614]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2580
diff
changeset
|
393 alarm(30); |
1006
0a4d0ed65e17
[gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
899
diff
changeset
|
394 if (sound_options & OPT_SOUND_BEEP) { |
1269
677e2c9e8baf
[gaim-migrate @ 1279]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1252
diff
changeset
|
395 g_print("\a"); |
1006
0a4d0ed65e17
[gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
899
diff
changeset
|
396 _exit(0); |
0a4d0ed65e17
[gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
899
diff
changeset
|
397 } |
0a4d0ed65e17
[gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
899
diff
changeset
|
398 |
1214
0baf39dc5437
[gaim-migrate @ 1224]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1109
diff
changeset
|
399 if (sound_cmd[0]) { |
0baf39dc5437
[gaim-migrate @ 1224]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1109
diff
changeset
|
400 char *args[4]; |
0baf39dc5437
[gaim-migrate @ 1224]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1109
diff
changeset
|
401 char command[4096]; |
2478
ad4a0b3f0032
[gaim-migrate @ 2491]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2467
diff
changeset
|
402 char *ms; |
ad4a0b3f0032
[gaim-migrate @ 2491]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2467
diff
changeset
|
403 if (strstr(sound_cmd, "\"%s\"")) |
ad4a0b3f0032
[gaim-migrate @ 2491]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2467
diff
changeset
|
404 g_snprintf(command, sizeof(command), sound_cmd, filename); |
ad4a0b3f0032
[gaim-migrate @ 2491]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2467
diff
changeset
|
405 else if ((ms = strstr(sound_cmd, "%s")) != NULL) { |
ad4a0b3f0032
[gaim-migrate @ 2491]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2467
diff
changeset
|
406 *ms = 0; |
ad4a0b3f0032
[gaim-migrate @ 2491]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2467
diff
changeset
|
407 g_snprintf(command, sizeof(command), "%s\"%s\"%s", sound_cmd, |
2580
86eaeb064e82
[gaim-migrate @ 2593]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2478
diff
changeset
|
408 filename, ms + 2); |
2478
ad4a0b3f0032
[gaim-migrate @ 2491]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2467
diff
changeset
|
409 } else |
ad4a0b3f0032
[gaim-migrate @ 2491]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2467
diff
changeset
|
410 g_snprintf(command, sizeof(command), sound_cmd); |
1214
0baf39dc5437
[gaim-migrate @ 1224]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1109
diff
changeset
|
411 args[0] = "sh"; |
0baf39dc5437
[gaim-migrate @ 1224]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1109
diff
changeset
|
412 args[1] = "-c"; |
0baf39dc5437
[gaim-migrate @ 1224]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1109
diff
changeset
|
413 args[2] = command; |
0baf39dc5437
[gaim-migrate @ 1224]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1109
diff
changeset
|
414 args[3] = NULL; |
0baf39dc5437
[gaim-migrate @ 1224]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1109
diff
changeset
|
415 execvp(args[0], args); |
0baf39dc5437
[gaim-migrate @ 1224]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1109
diff
changeset
|
416 _exit(0); |
0baf39dc5437
[gaim-migrate @ 1224]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1109
diff
changeset
|
417 } |
1006
0a4d0ed65e17
[gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
899
diff
changeset
|
418 #ifdef ESD_SOUND |
2580
86eaeb064e82
[gaim-migrate @ 2593]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2478
diff
changeset
|
419 else if (sound_options & OPT_SOUND_ESD) { |
86eaeb064e82
[gaim-migrate @ 2593]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2478
diff
changeset
|
420 if (esd_play_file(NULL, filename, 1)) |
86eaeb064e82
[gaim-migrate @ 2593]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2478
diff
changeset
|
421 _exit(0); |
86eaeb064e82
[gaim-migrate @ 2593]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2478
diff
changeset
|
422 } |
1006
0a4d0ed65e17
[gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
899
diff
changeset
|
423 #endif |
0a4d0ed65e17
[gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
899
diff
changeset
|
424 |
2186
08781af8e3a9
[gaim-migrate @ 2196]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2183
diff
changeset
|
425 #ifdef ARTSC_SOUND |
2580
86eaeb064e82
[gaim-migrate @ 2593]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2478
diff
changeset
|
426 else if (sound_options & OPT_SOUND_ARTSC) { |
86eaeb064e82
[gaim-migrate @ 2593]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2478
diff
changeset
|
427 if (artsc_play_file(filename)) |
86eaeb064e82
[gaim-migrate @ 2593]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2478
diff
changeset
|
428 _exit(0); |
86eaeb064e82
[gaim-migrate @ 2593]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2478
diff
changeset
|
429 } |
2186
08781af8e3a9
[gaim-migrate @ 2196]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2183
diff
changeset
|
430 #endif |
08781af8e3a9
[gaim-migrate @ 2196]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2183
diff
changeset
|
431 |
1109
c73736fa0b7c
[gaim-migrate @ 1119]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1057
diff
changeset
|
432 #ifdef NAS_SOUND |
2580
86eaeb064e82
[gaim-migrate @ 2593]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2478
diff
changeset
|
433 else if (sound_options & OPT_SOUND_NAS) { |
86eaeb064e82
[gaim-migrate @ 2593]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2478
diff
changeset
|
434 if (play_nas_file(filename)) |
86eaeb064e82
[gaim-migrate @ 2593]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2478
diff
changeset
|
435 _exit(0); |
86eaeb064e82
[gaim-migrate @ 2593]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2478
diff
changeset
|
436 } |
1109
c73736fa0b7c
[gaim-migrate @ 1119]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1057
diff
changeset
|
437 #endif |
2580
86eaeb064e82
[gaim-migrate @ 2593]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2478
diff
changeset
|
438 else if ((sound_options & OPT_SOUND_NORMAL) && |
86eaeb064e82
[gaim-migrate @ 2593]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2478
diff
changeset
|
439 can_play_audio()) { |
1006
0a4d0ed65e17
[gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
899
diff
changeset
|
440 play_audio_file(filename); |
0a4d0ed65e17
[gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
899
diff
changeset
|
441 _exit(0); |
0a4d0ed65e17
[gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
899
diff
changeset
|
442 } |
0a4d0ed65e17
[gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
899
diff
changeset
|
443 |
0a4d0ed65e17
[gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
899
diff
changeset
|
444 _exit(0); |
0a4d0ed65e17
[gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
899
diff
changeset
|
445 } else { |
2370
25e7c2a68ed2
[gaim-migrate @ 2383]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2242
diff
changeset
|
446 g_timeout_add(100, clean_pid, NULL); |
1006
0a4d0ed65e17
[gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
899
diff
changeset
|
447 } |
0a4d0ed65e17
[gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
899
diff
changeset
|
448 } |
0a4d0ed65e17
[gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
899
diff
changeset
|
449 |
133
e277d5f0c1dd
[gaim-migrate @ 143]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
108
diff
changeset
|
450 void play(unsigned char *data, int size) |
1 | 451 { |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1235
diff
changeset
|
452 int pid; |
1 | 453 |
454 #ifdef _WIN32 | |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1235
diff
changeset
|
455 return; |
1 | 456 #endif |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1235
diff
changeset
|
457 |
1 | 458 pid = fork(); |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1235
diff
changeset
|
459 |
1 | 460 if (pid < 0) |
461 return; | |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1235
diff
changeset
|
462 else if (pid == 0) { |
2601
61952dde7677
[gaim-migrate @ 2614]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2580
diff
changeset
|
463 alarm(30); |
775
9614e69f68ca
[gaim-migrate @ 785]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
668
diff
changeset
|
464 if (sound_options & OPT_SOUND_BEEP) { |
1269
677e2c9e8baf
[gaim-migrate @ 1279]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1252
diff
changeset
|
465 g_print("\a"); |
775
9614e69f68ca
[gaim-migrate @ 785]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
668
diff
changeset
|
466 _exit(0); |
9614e69f68ca
[gaim-migrate @ 785]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
668
diff
changeset
|
467 } |
1 | 468 #ifdef ESD_SOUND |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1235
diff
changeset
|
469 /* ESD is our player of choice. Are we OK to |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1235
diff
changeset
|
470 * go there? */ |
2580
86eaeb064e82
[gaim-migrate @ 2593]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2478
diff
changeset
|
471 else if (sound_options & OPT_SOUND_ESD) { |
86eaeb064e82
[gaim-migrate @ 2593]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2478
diff
changeset
|
472 if (can_play_esd()) { |
86eaeb064e82
[gaim-migrate @ 2593]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2478
diff
changeset
|
473 if (play_esd(data, size)) |
86eaeb064e82
[gaim-migrate @ 2593]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2478
diff
changeset
|
474 _exit(0); |
86eaeb064e82
[gaim-migrate @ 2593]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2478
diff
changeset
|
475 } |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1235
diff
changeset
|
476 } |
1 | 477 #endif |
478 | |
2179
64d8ef561763
[gaim-migrate @ 2189]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2158
diff
changeset
|
479 #ifdef ARTSC_SOUND |
64d8ef561763
[gaim-migrate @ 2189]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2158
diff
changeset
|
480 /* ArtsC is the new second choice. */ |
2580
86eaeb064e82
[gaim-migrate @ 2593]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2478
diff
changeset
|
481 else if (sound_options & OPT_SOUND_ARTSC) { |
86eaeb064e82
[gaim-migrate @ 2593]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2478
diff
changeset
|
482 if (can_play_artsc()) { |
86eaeb064e82
[gaim-migrate @ 2593]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2478
diff
changeset
|
483 if (play_artsc(data, size)) |
86eaeb064e82
[gaim-migrate @ 2593]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2478
diff
changeset
|
484 _exit(0); |
86eaeb064e82
[gaim-migrate @ 2593]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2478
diff
changeset
|
485 } |
2179
64d8ef561763
[gaim-migrate @ 2189]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2158
diff
changeset
|
486 } |
64d8ef561763
[gaim-migrate @ 2189]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2158
diff
changeset
|
487 #endif |
64d8ef561763
[gaim-migrate @ 2189]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2158
diff
changeset
|
488 |
1 | 489 #ifdef NAS_SOUND |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1235
diff
changeset
|
490 /* NAS is our second choice setup. */ |
2580
86eaeb064e82
[gaim-migrate @ 2593]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2478
diff
changeset
|
491 else if (sound_options & OPT_SOUND_NAS) { |
86eaeb064e82
[gaim-migrate @ 2593]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2478
diff
changeset
|
492 if (can_play_nas()) { |
86eaeb064e82
[gaim-migrate @ 2593]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2478
diff
changeset
|
493 if (play_nas(data, size)) |
86eaeb064e82
[gaim-migrate @ 2593]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2478
diff
changeset
|
494 _exit(0); |
86eaeb064e82
[gaim-migrate @ 2593]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2478
diff
changeset
|
495 } |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1235
diff
changeset
|
496 } |
1 | 497 #endif |
498 | |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1235
diff
changeset
|
499 /* Lastly, we can try just plain old /dev/audio */ |
2580
86eaeb064e82
[gaim-migrate @ 2593]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2478
diff
changeset
|
500 else if (sound_options & OPT_SOUND_NORMAL) { |
86eaeb064e82
[gaim-migrate @ 2593]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2478
diff
changeset
|
501 if (can_play_audio()) { |
86eaeb064e82
[gaim-migrate @ 2593]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2478
diff
changeset
|
502 play_audio(data, size); |
86eaeb064e82
[gaim-migrate @ 2593]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2478
diff
changeset
|
503 _exit(0); |
86eaeb064e82
[gaim-migrate @ 2593]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2478
diff
changeset
|
504 } |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1235
diff
changeset
|
505 } |
668
c9b66c710283
[gaim-migrate @ 678]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
655
diff
changeset
|
506 |
c9b66c710283
[gaim-migrate @ 678]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
655
diff
changeset
|
507 _exit(0); |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1235
diff
changeset
|
508 } else { |
2370
25e7c2a68ed2
[gaim-migrate @ 2383]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2242
diff
changeset
|
509 g_timeout_add(100, clean_pid, NULL); |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1235
diff
changeset
|
510 } |
1 | 511 } |
512 | |
133
e277d5f0c1dd
[gaim-migrate @ 143]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
108
diff
changeset
|
513 extern int logins_not_muted; |
1 | 514 |
515 void play_sound(int sound) | |
516 { | |
517 | |
1235
a9cf2f61a7b1
[gaim-migrate @ 1245]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1214
diff
changeset
|
518 if (awaymessage && !(sound_options & OPT_SOUND_WHEN_AWAY)) |
a9cf2f61a7b1
[gaim-migrate @ 1245]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1214
diff
changeset
|
519 return; |
a9cf2f61a7b1
[gaim-migrate @ 1245]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1214
diff
changeset
|
520 |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1235
diff
changeset
|
521 switch (sound) { |
1 | 522 case BUDDY_ARRIVE: |
1006
0a4d0ed65e17
[gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
899
diff
changeset
|
523 if ((sound_options & OPT_SOUND_LOGIN) && logins_not_muted) { |
0a4d0ed65e17
[gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
899
diff
changeset
|
524 if (sound_file[BUDDY_ARRIVE]) { |
0a4d0ed65e17
[gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
899
diff
changeset
|
525 play_file(sound_file[BUDDY_ARRIVE]); |
0a4d0ed65e17
[gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
899
diff
changeset
|
526 } else { |
0a4d0ed65e17
[gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
899
diff
changeset
|
527 play(BuddyArrive, sizeof(BuddyArrive)); |
0a4d0ed65e17
[gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
899
diff
changeset
|
528 } |
0a4d0ed65e17
[gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
899
diff
changeset
|
529 } |
1 | 530 break; |
531 case BUDDY_LEAVE: | |
1006
0a4d0ed65e17
[gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
899
diff
changeset
|
532 if (sound_options & OPT_SOUND_LOGOUT) { |
0a4d0ed65e17
[gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
899
diff
changeset
|
533 if (sound_file[BUDDY_LEAVE]) { |
0a4d0ed65e17
[gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
899
diff
changeset
|
534 play_file(sound_file[BUDDY_LEAVE]); |
0a4d0ed65e17
[gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
899
diff
changeset
|
535 } else { |
0a4d0ed65e17
[gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
899
diff
changeset
|
536 play(BuddyLeave, sizeof(BuddyLeave)); |
0a4d0ed65e17
[gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
899
diff
changeset
|
537 } |
0a4d0ed65e17
[gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
899
diff
changeset
|
538 } |
0a4d0ed65e17
[gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
899
diff
changeset
|
539 break; |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1235
diff
changeset
|
540 case FIRST_RECEIVE: |
1006
0a4d0ed65e17
[gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
899
diff
changeset
|
541 if (sound_options & OPT_SOUND_FIRST_RCV) { |
0a4d0ed65e17
[gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
899
diff
changeset
|
542 if (sound_file[FIRST_RECEIVE]) { |
0a4d0ed65e17
[gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
899
diff
changeset
|
543 play_file(sound_file[FIRST_RECEIVE]); |
0a4d0ed65e17
[gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
899
diff
changeset
|
544 } else { |
0a4d0ed65e17
[gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
899
diff
changeset
|
545 play(Receive, sizeof(Receive)); |
0a4d0ed65e17
[gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
899
diff
changeset
|
546 } |
0a4d0ed65e17
[gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
899
diff
changeset
|
547 } |
0a4d0ed65e17
[gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
899
diff
changeset
|
548 break; |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1235
diff
changeset
|
549 case RECEIVE: |
1006
0a4d0ed65e17
[gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
899
diff
changeset
|
550 if (sound_options & OPT_SOUND_RECV) { |
0a4d0ed65e17
[gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
899
diff
changeset
|
551 if (sound_file[RECEIVE]) { |
0a4d0ed65e17
[gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
899
diff
changeset
|
552 play_file(sound_file[RECEIVE]); |
0a4d0ed65e17
[gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
899
diff
changeset
|
553 } else { |
0a4d0ed65e17
[gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
899
diff
changeset
|
554 play(Receive, sizeof(Receive)); |
0a4d0ed65e17
[gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
899
diff
changeset
|
555 } |
0a4d0ed65e17
[gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
899
diff
changeset
|
556 } |
1 | 557 break; |
558 case SEND: | |
1006
0a4d0ed65e17
[gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
899
diff
changeset
|
559 if (sound_options & OPT_SOUND_SEND) { |
0a4d0ed65e17
[gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
899
diff
changeset
|
560 if (sound_file[SEND]) { |
0a4d0ed65e17
[gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
899
diff
changeset
|
561 play_file(sound_file[SEND]); |
0a4d0ed65e17
[gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
899
diff
changeset
|
562 } else { |
0a4d0ed65e17
[gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
899
diff
changeset
|
563 play(Send, sizeof(Send)); |
0a4d0ed65e17
[gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
899
diff
changeset
|
564 } |
0a4d0ed65e17
[gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
899
diff
changeset
|
565 } |
1 | 566 break; |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1235
diff
changeset
|
567 case CHAT_JOIN: |
1006
0a4d0ed65e17
[gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
899
diff
changeset
|
568 if (sound_options & OPT_SOUND_CHAT_JOIN) { |
0a4d0ed65e17
[gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
899
diff
changeset
|
569 if (sound_file[CHAT_JOIN]) { |
0a4d0ed65e17
[gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
899
diff
changeset
|
570 play_file(sound_file[CHAT_JOIN]); |
0a4d0ed65e17
[gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
899
diff
changeset
|
571 } else { |
0a4d0ed65e17
[gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
899
diff
changeset
|
572 play(BuddyArrive, sizeof(BuddyArrive)); |
0a4d0ed65e17
[gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
899
diff
changeset
|
573 } |
0a4d0ed65e17
[gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
899
diff
changeset
|
574 } |
1 | 575 break; |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1235
diff
changeset
|
576 case CHAT_LEAVE: |
1006
0a4d0ed65e17
[gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
899
diff
changeset
|
577 if (sound_options & OPT_SOUND_CHAT_PART) { |
0a4d0ed65e17
[gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
899
diff
changeset
|
578 if (sound_file[CHAT_LEAVE]) { |
0a4d0ed65e17
[gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
899
diff
changeset
|
579 play_file(sound_file[CHAT_LEAVE]); |
0a4d0ed65e17
[gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
899
diff
changeset
|
580 } else { |
0a4d0ed65e17
[gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
899
diff
changeset
|
581 play(BuddyLeave, sizeof(BuddyLeave)); |
0a4d0ed65e17
[gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
899
diff
changeset
|
582 } |
0a4d0ed65e17
[gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
899
diff
changeset
|
583 } |
1 | 584 break; |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1235
diff
changeset
|
585 case CHAT_YOU_SAY: |
1006
0a4d0ed65e17
[gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
899
diff
changeset
|
586 if (sound_options & OPT_SOUND_CHAT_YOU_SAY) { |
0a4d0ed65e17
[gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
899
diff
changeset
|
587 if (sound_file[CHAT_YOU_SAY]) { |
0a4d0ed65e17
[gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
899
diff
changeset
|
588 play_file(sound_file[CHAT_YOU_SAY]); |
0a4d0ed65e17
[gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
899
diff
changeset
|
589 } else { |
0a4d0ed65e17
[gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
899
diff
changeset
|
590 play(Send, sizeof(Send)); |
0a4d0ed65e17
[gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
899
diff
changeset
|
591 } |
0a4d0ed65e17
[gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
899
diff
changeset
|
592 } |
0a4d0ed65e17
[gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
899
diff
changeset
|
593 break; |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1235
diff
changeset
|
594 case CHAT_SAY: |
1006
0a4d0ed65e17
[gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
899
diff
changeset
|
595 if (sound_options & OPT_SOUND_CHAT_SAY) { |
0a4d0ed65e17
[gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
899
diff
changeset
|
596 if (sound_file[CHAT_SAY]) { |
0a4d0ed65e17
[gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
899
diff
changeset
|
597 play_file(sound_file[CHAT_SAY]); |
0a4d0ed65e17
[gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
899
diff
changeset
|
598 } else { |
0a4d0ed65e17
[gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
899
diff
changeset
|
599 play(Receive, sizeof(Receive)); |
0a4d0ed65e17
[gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
899
diff
changeset
|
600 } |
0a4d0ed65e17
[gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
899
diff
changeset
|
601 } |
1 | 602 break; |
1694 | 603 case POUNCE_DEFAULT: |
604 if (sound_file[POUNCE_DEFAULT]) { | |
605 play_file(sound_file[POUNCE_DEFAULT]); | |
606 } else { | |
607 play(RedAlert, sizeof(RedAlert)); | |
608 } | |
609 break; | |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1235
diff
changeset
|
610 } |
64 | 611 } |