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