comparison src/sound.c @ 4009:a9541aded628

[gaim-migrate @ 4209] robot101 did not test his patch. faceprint fixed it at least some. nas is still broke committer: Tailor Script <tailor@pidgin.im>
author Luke Schierer <lschiere@pidgin.im>
date Wed, 27 Nov 2002 22:00:23 +0000
parents b2520034b62f
children 2b18ea0ade13
comparison
equal deleted inserted replaced
4008:56b8d3717eac 4009:a9541aded628
42 42
43 #ifdef ESD_SOUND 43 #ifdef ESD_SOUND
44 #include <esd.h> 44 #include <esd.h>
45 #endif 45 #endif
46 46
47 #ifdef ARTSC_SOUND
48 #include <artsc.h>
49 #endif
50
51 #ifdef NAS_SOUND 47 #ifdef NAS_SOUND
52 #include <audio/audiolib.h> 48 #include <audio/audiolib.h>
53 #endif 49 #endif
54 50
55 #include "gaim.h" 51 #include "gaim.h"
60 * if you want it to get displayed in the prefs dialog, it needs * 56 * if you want it to get displayed in the prefs dialog, it needs *
61 * to be added to the sound_order array in prefs.c, if not, and * 57 * to be added to the sound_order array in prefs.c, if not, and *
62 * it has no option bit, set it to 0. the order here has to match * 58 * it has no option bit, set it to 0. the order here has to match *
63 * the defines in gaim.h. -Robot101 */ 59 * the defines in gaim.h. -Robot101 */
64 struct sound_struct sounds[NUM_SOUNDS] = { 60 struct sound_struct sounds[NUM_SOUNDS] = {
65 {N_("Buddy logs in"), OPT_SOUND_LOGIN, "arrive.wav"}, 61 {N_("Buddy logs in"), OPT_SOUND_LOGIN, "BuddyArrive.wav"},
66 {N_("Buddy logs out"), OPT_SOUND_LOGOUT, "leave.wav"}, 62 {N_("Buddy logs out"), OPT_SOUND_LOGOUT, "BuddyLeave.wav"},
67 {N_("Message received"), OPT_SOUND_RECV, "receive.wav"}, 63 {N_("Message received"), OPT_SOUND_RECV, "Receive.wav"},
68 {N_("Message received begins conversation"), OPT_SOUND_FIRST_RCV, "receive.wav"}, 64 {N_("Message received begins conversation"), OPT_SOUND_FIRST_RCV, "Receive.wav"},
69 {N_("Message sent"), OPT_SOUND_SEND, "send.wav"}, 65 {N_("Message sent"), OPT_SOUND_SEND, "Send.wav"},
70 {N_("Person enters chat"), OPT_SOUND_CHAT_JOIN, "arrive.wav"}, 66 {N_("Person enters chat"), OPT_SOUND_CHAT_JOIN, "BuddyArrive.wav"},
71 {N_("Person leaves chat"), OPT_SOUND_CHAT_PART, "leave.wav"}, 67 {N_("Person leaves chat"), OPT_SOUND_CHAT_PART, "BuddyLeave.wav"},
72 {N_("You talk in chat"), OPT_SOUND_CHAT_YOU_SAY, "send.wav"}, 68 {N_("You talk in chat"), OPT_SOUND_CHAT_YOU_SAY, "Send.wav"},
73 {N_("Others talk in chat"), OPT_SOUND_CHAT_SAY, "receive.wav"}, 69 {N_("Others talk in chat"), OPT_SOUND_CHAT_SAY, "Receive.wav"},
74 /* this isn't a terminator, it's the buddy pounce default sound event ;-) */ 70 /* this isn't a terminator, it's the buddy pounce default sound event ;-) */
75 {NULL, 0, "redalert.wav"}, 71 {NULL, 0, "RedAlert.wav"},
76 {N_("Someone says your name in chat"), OPT_SOUND_CHAT_NICK, "redalert.wav"} 72 {N_("Someone says your name in chat"), OPT_SOUND_CHAT_NICK, "RedAlert.wav"}
77 }; 73 };
78 int sound_order[] = { 74 int sound_order[] = {
79 SND_BUDDY_ARRIVE, SND_BUDDY_LEAVE, 75 SND_BUDDY_ARRIVE, SND_BUDDY_LEAVE,
80 SND_FIRST_RECEIVE, SND_RECEIVE, SND_SEND, 76 SND_FIRST_RECEIVE, SND_RECEIVE, SND_SEND,
81 SND_CHAT_JOIN, SND_CHAT_LEAVE, 77 SND_CHAT_JOIN, SND_CHAT_LEAVE,
157 return 1; 153 return 1;
158 } 154 }
159 155
160 #endif 156 #endif
161 157
162 #ifdef ARTSC_SOUND
163
164 static int can_play_artsc()
165 {
166 int error;
167
168 error = arts_init();
169 if (error < 0)
170 return 0;
171
172 return 1;
173 }
174
175 static int artsc_play_file(char *file)
176 {
177 struct stat stat_buf;
178 unsigned char *buf = NULL;
179 int result = 0;
180 int fd = -1;
181
182 if (!can_play_artsc())
183 return 0;
184
185 fd = open(file, O_RDONLY);
186 if (fd < 0)
187 return 0;
188
189 if (fstat(fd, &stat_buf)) {
190 close(fd);
191 return 0;
192 }
193
194 if (!stat_buf.st_size) {
195 close(fd);
196 return 0;
197 }
198
199 buf = g_malloc(stat_buf.st_size);
200 if (!buf) {
201 close(fd);
202 return 0;
203 }
204
205 if (read(fd, buf, stat_buf.st_size) < 0) {
206 g_free(buf);
207 close(fd);
208 return 0;
209 }
210
211 result = play_artsc(buf, stat_buf.st_size);
212
213 g_free(buf);
214 close(fd);
215 return result;
216 }
217
218 #endif /* ARTSC_SOUND */
219
220 #ifdef NAS_SOUND 158 #ifdef NAS_SOUND
221 159
222 char nas_server[] = "localhost"; 160 char nas_server[] = "localhost";
223 AuServer *nas_serv = NULL; 161 AuServer *nas_serv = NULL;
224 162
316 if (esd_play_file(NULL, filename, 1)) 254 if (esd_play_file(NULL, filename, 1))
317 _exit(0); 255 _exit(0);
318 } 256 }
319 #endif 257 #endif
320 258
321 #ifdef ARTSC_SOUND
322 else if (sound_options & OPT_SOUND_ARTSC) { 259 else if (sound_options & OPT_SOUND_ARTSC) {
323 if (artsc_play_file(filename)) 260 char *args[3];
324 _exit(0); 261 args[0] = "artsplay";
325 } 262 args[1] = filename;
326 #endif 263 args[2] = NULL;
264 execvp(args[0], args);
265 _exit(0);
266 }
327 267
328 #ifdef NAS_SOUND 268 #ifdef NAS_SOUND
329 else if (sound_options & OPT_SOUND_NAS) { 269 else if (sound_options & OPT_SOUND_NAS) {
330 if (play_nas_file(filename)) 270 if (play_nas_file(filename))
331 _exit(0); 271 _exit(0);