annotate src/sound.c @ 900:e18815f5a4e9

[gaim-migrate @ 910] libfaim changes la la la committer: Tailor Script <tailor@pidgin.im>
author Eric Warmenhoven <eric@warmenhoven.org>
date Wed, 13 Sep 2000 23:48:43 +0000
parents 88d1edcd7cd6
children 0a4d0ed65e17
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1 /*
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2 * gaim
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3 *
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
4 * Copyright (C) 1998-1999, Mark Spencer <markster@marko.net>
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
5 *
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
6 * This program is free software; you can redistribute it and/or modify
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
7 * it under the terms of the GNU General Public License as published by
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
8 * the Free Software Foundation; either version 2 of the License, or
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
9 * (at your option) any later version.
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
10 *
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
11 * This program is distributed in the hope that it will be useful,
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
14 * GNU General Public License for more details.
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
15 *
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
16 * You should have received a copy of the GNU General Public License
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
17 * along with this program; if not, write to the Free Software
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
19 *
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
20 */
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
21
349
b402a23f35df [gaim-migrate @ 359]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 338
diff changeset
22 #ifdef HAVE_CONFIG_H
b402a23f35df [gaim-migrate @ 359]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 338
diff changeset
23 #include "../config.h"
b402a23f35df [gaim-migrate @ 359]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 338
diff changeset
24 #endif
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
25 #include <stdio.h>
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
26 #include <string.h>
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
27 #include <sys/time.h>
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
28 #include <unistd.h>
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
29 #include <gtk/gtk.h>
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
30 #include <fcntl.h>
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
31 #include <sys/wait.h>
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
32 #include <sys/signal.h>
63
12894b62d206 [gaim-migrate @ 73]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
33 #include <unistd.h>
12894b62d206 [gaim-migrate @ 73]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
34 #include <sys/types.h>
12894b62d206 [gaim-migrate @ 73]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
35 #include <sys/stat.h>
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
36
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
37 #ifdef ESD_SOUND
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
38 #include <esd.h>
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
39 #endif
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
40
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
41 #ifdef NAS_SOUND
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
42 #include <audio/audiolib.h>
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
43 #endif
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
44
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
45 #include "gaim.h"
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
46 #include "sounds/BuddyArrive.h"
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
47 #include "sounds/BuddyLeave.h"
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
48 #include "sounds/Send.h"
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
49 #include "sounds/Receive.h"
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
50
655
6ba20a0089d8 [gaim-migrate @ 665]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 606
diff changeset
51 static int check_dev(char *dev)
6ba20a0089d8 [gaim-migrate @ 665]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 606
diff changeset
52 {
6ba20a0089d8 [gaim-migrate @ 665]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 606
diff changeset
53 struct stat stat_buf;
6ba20a0089d8 [gaim-migrate @ 665]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 606
diff changeset
54 uid_t user = getuid();
899
88d1edcd7cd6 [gaim-migrate @ 909]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 778
diff changeset
55 gid_t group = getgid(),
88d1edcd7cd6 [gaim-migrate @ 909]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 778
diff changeset
56 other_groups[32];
88d1edcd7cd6 [gaim-migrate @ 909]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 778
diff changeset
57 int i, numgroups;
88d1edcd7cd6 [gaim-migrate @ 909]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 778
diff changeset
58
88d1edcd7cd6 [gaim-migrate @ 909]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 778
diff changeset
59 if ((numgroups = getgroups (32, other_groups)) == -1)
88d1edcd7cd6 [gaim-migrate @ 909]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 778
diff changeset
60 return 0;
655
6ba20a0089d8 [gaim-migrate @ 665]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 606
diff changeset
61 if (stat(dev, &stat_buf))
6ba20a0089d8 [gaim-migrate @ 665]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 606
diff changeset
62 return 0;
6ba20a0089d8 [gaim-migrate @ 665]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 606
diff changeset
63 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
64 return 1;
899
88d1edcd7cd6 [gaim-migrate @ 909]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 778
diff changeset
65 if (stat_buf.st_mode & S_IWGRP) {
88d1edcd7cd6 [gaim-migrate @ 909]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 778
diff changeset
66 if (group == stat_buf.st_gid)
88d1edcd7cd6 [gaim-migrate @ 909]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 778
diff changeset
67 return 1;
88d1edcd7cd6 [gaim-migrate @ 909]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 778
diff changeset
68 for (i = 0; i < numgroups; i++)
88d1edcd7cd6 [gaim-migrate @ 909]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 778
diff changeset
69 if (other_groups[i] == 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 }
655
6ba20a0089d8 [gaim-migrate @ 665]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 606
diff changeset
72 if (stat_buf.st_mode & S_IWOTH)
6ba20a0089d8 [gaim-migrate @ 665]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 606
diff changeset
73 return 1;
6ba20a0089d8 [gaim-migrate @ 665]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 606
diff changeset
74 return 0;
6ba20a0089d8 [gaim-migrate @ 665]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 606
diff changeset
75 }
6ba20a0089d8 [gaim-migrate @ 665]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 606
diff changeset
76
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
77
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
78 static void play_audio(char *data, int size)
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
79 {
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
80 int fd;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
81
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
82 fd = open("/dev/audio", O_WRONLY | O_EXCL);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
83 if (fd < 0)
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
84 return;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
85 write(fd, data, size);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
86 close(fd);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
87 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
88
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
89 static int can_play_audio()
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
90 {
655
6ba20a0089d8 [gaim-migrate @ 665]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 606
diff changeset
91 return check_dev("/dev/audio");
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
92 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
93
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
94
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
95 #ifdef ESD_SOUND
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
96 /*
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
97 ** This routine converts from ulaw to 16 bit linear.
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
98 **
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
99 ** Craig Reese: IDA/Supercomputing Research Center
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
100 ** 29 September 1989
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
101 **
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
102 ** References:
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
103 ** 1) CCITT Recommendation G.711 (very difficult to follow)
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
104 ** 2) MIL-STD-188-113,"Interoperability and Performance Standards
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
105 ** for Analog-to_Digital Conversion Techniques,"
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
106 ** 17 February 1987
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
107 **
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
108 ** Input: 8 bit ulaw sample
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
109 ** Output: signed 16 bit linear sample
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
110 ** Z-note -- this is from libaudiofile. Thanks guys!
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
111 */
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
112
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
113 int _af_ulaw2linear (unsigned char ulawbyte)
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
114 {
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
115 static int exp_lut[8] = {0,132,396,924,1980,4092,8316,16764};
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
116 int sign, exponent, mantissa, sample;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
117
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
118 ulawbyte = ~ulawbyte;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
119 sign = (ulawbyte & 0x80);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
120 exponent = (ulawbyte >> 4) & 0x07;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
121 mantissa = ulawbyte & 0x0F;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
122 sample = exp_lut[exponent] + (mantissa << (exponent + 3));
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
123 if (sign != 0) sample = -sample;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
124
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
125 return(sample);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
126 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
127
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
128
354
2b91e42bff70 [gaim-migrate @ 364]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 349
diff changeset
129 int esd_fd;
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
130
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
131 static int play_esd(unsigned char *data, int size)
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
132 {
354
2b91e42bff70 [gaim-migrate @ 364]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 349
diff changeset
133 int i;
79
bfdc427b936d [gaim-migrate @ 89]
Rob Flynn <gaim@robflynn.com>
parents: 64
diff changeset
134 guint16 *lineardata;
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
135
79
bfdc427b936d [gaim-migrate @ 89]
Rob Flynn <gaim@robflynn.com>
parents: 64
diff changeset
136 lineardata = g_malloc(size * 2);
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
137
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
138 for (i=0; i<size; i++)
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
139 lineardata[i] = _af_ulaw2linear(data[i]);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
140
354
2b91e42bff70 [gaim-migrate @ 364]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 349
diff changeset
141 write(esd_fd, lineardata, size * 2);
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
142
354
2b91e42bff70 [gaim-migrate @ 364]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 349
diff changeset
143 close(esd_fd);
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
144 g_free(lineardata);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
145
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
146 return 1;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
147
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
148 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
149
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
150 static int can_play_esd()
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
151 {
354
2b91e42bff70 [gaim-migrate @ 364]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 349
diff changeset
152 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
153
354
2b91e42bff70 [gaim-migrate @ 364]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 349
diff changeset
154 esd_fd = esd_play_stream(format, 8012, NULL, "gaim");
2b91e42bff70 [gaim-migrate @ 364]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 349
diff changeset
155
2b91e42bff70 [gaim-migrate @ 364]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 349
diff changeset
156 if (esd_fd < 0) {
2b91e42bff70 [gaim-migrate @ 364]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 349
diff changeset
157 return 0;
2b91e42bff70 [gaim-migrate @ 364]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 349
diff changeset
158 }
2b91e42bff70 [gaim-migrate @ 364]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 349
diff changeset
159
2b91e42bff70 [gaim-migrate @ 364]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 349
diff changeset
160 return 1;
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
161 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
162
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
163 #endif
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
164
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
165 #ifdef NAS_SOUND
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
166
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
167 char nas_server[] = "localhost";
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
168 AuServer *nas_serv = NULL;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
169
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
170 static AuBool
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
171 NasEventHandler(AuServer *aud, AuEvent *ev, AuEventHandlerRec *handler)
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
172 {
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
173 AuElementNotifyEvent *event = (AuElementNotifyEvent *) ev;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
174
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
175 if (ev->type == AuEventTypeElementNotify) {
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
176 switch (event->kind) {
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
177 case AuElementNotifyKindState:
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
178 switch (event->cur_state) {
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
179 case AuStateStop:
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
180 _exit(0);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
181 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
182 break;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
183 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
184 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
185 return AuTrue;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
186 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
187
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
188
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
189 static int play_nas(unsigned char *data, int size)
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
190 {
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
191 AuDeviceID device = AuNone;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
192 AuFlowID flow;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
193 AuElement elements[3];
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
194 int i, n, w;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
195
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
196 /* look for an output device */
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
197 for (i = 0; i < AuServerNumDevices(nas_serv); i++) {
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
198 if ((AuDeviceKind(AuServerDevice(nas_serv, i)) ==
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
199 AuComponentKindPhysicalOutput) &&
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
200 AuDeviceNumTracks(AuServerDevice(nas_serv, i)) == 1) {
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
201 device = AuDeviceIdentifier(AuServerDevice(nas_serv, i));
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
202 break;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
203 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
204 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
205
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
206 if (device == AuNone)
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
207 return 0;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
208
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
209 if (!(flow = AuCreateFlow(nas_serv, NULL)))
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
210 return 0;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
211
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
212
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
213 AuMakeElementImportClient(&elements[0], 8012, AuFormatULAW8,
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
214 1, AuTrue, size, size/2, 0, NULL);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
215 AuMakeElementExportDevice(&elements[1], 0, device, 8012,
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
216 AuUnlimitedSamples, 0, NULL);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
217 AuSetElements(nas_serv, flow, AuTrue, 2, elements, NULL);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
218
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
219 AuStartFlow(nas_serv, flow, NULL);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
220
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
221 AuWriteElement(nas_serv, flow, 0, size, data, AuTrue, NULL);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
222
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
223 AuRegisterEventHandler(nas_serv, AuEventHandlerIDMask, 0, flow,
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
224 NasEventHandler, NULL);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
225
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
226 while(1) {
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
227 AuHandleEvents(nas_serv);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
228 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
229
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
230 return 1;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
231 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
232
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
233 static int can_play_nas()
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
234 {
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
235 if ((nas_serv = AuOpenServer(NULL, 0, NULL, 0, NULL, NULL)))
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
236 return 1;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
237 return 0;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
238 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
239
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
240 #endif
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
241
133
e277d5f0c1dd [gaim-migrate @ 143]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 108
diff changeset
242 void play(unsigned char *data, int size)
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
243 {
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
244 int pid;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
245
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
246 #ifdef _WIN32
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
247 return;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
248 #endif
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
249
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
250 pid = fork();
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
251
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
252 if (pid < 0)
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
253 return;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
254 else if (pid == 0) {
775
9614e69f68ca [gaim-migrate @ 785]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 668
diff changeset
255 if (sound_options & OPT_SOUND_BEEP) {
777
1d60fb2c3b3b [gaim-migrate @ 787]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 775
diff changeset
256 printf("\a");
778
035d3115c6fe [gaim-migrate @ 788]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 777
diff changeset
257 fflush(stdout);
775
9614e69f68ca [gaim-migrate @ 785]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 668
diff changeset
258 _exit(0);
9614e69f68ca [gaim-migrate @ 785]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 668
diff changeset
259 }
9614e69f68ca [gaim-migrate @ 785]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 668
diff changeset
260
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
261 #ifdef ESD_SOUND
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
262 /* ESD is our player of choice. Are we OK to
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
263 * go there? */
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
264 if (can_play_esd()) {
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
265 if (play_esd(data, size))
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
266 _exit(0);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
267 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
268 #endif
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
269
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
270 #ifdef NAS_SOUND
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
271 /* NAS is our second choice setup. */
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
272 if (can_play_nas()) {
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
273 if (play_nas(data, size))
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
274 _exit(0);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
275 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
276 #endif
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
277
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
278 /* Lastly, we can try just plain old /dev/audio */
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
279 if (can_play_audio()) {
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
280 play_audio(data, size);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
281 _exit(0);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
282 }
668
c9b66c710283 [gaim-migrate @ 678]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 655
diff changeset
283
c9b66c710283 [gaim-migrate @ 678]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 655
diff changeset
284 _exit(0);
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
285 } else {
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
286 gtk_timeout_add(100, (GtkFunction)clean_pid, NULL);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
287 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
288 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
289
133
e277d5f0c1dd [gaim-migrate @ 143]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 108
diff changeset
290 extern int logins_not_muted;
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
291
606
eaab8abda2c0 [gaim-migrate @ 616]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 451
diff changeset
292 #ifdef USE_GNOME
eaab8abda2c0 [gaim-migrate @ 616]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 451
diff changeset
293 void gnome_play_sound(int sound)
451
7b49c67e561c [gaim-migrate @ 461]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 354
diff changeset
294 #else
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
295 void play_sound(int sound)
451
7b49c67e561c [gaim-migrate @ 461]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 354
diff changeset
296 #endif
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
297 {
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
298
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
299 switch(sound) {
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
300 case BUDDY_ARRIVE:
133
e277d5f0c1dd [gaim-migrate @ 143]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 108
diff changeset
301 if ((sound_options & OPT_SOUND_LOGIN) && logins_not_muted)
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
302 play(BuddyArrive, sizeof(BuddyArrive));
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
303 break;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
304 case BUDDY_LEAVE:
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
305 if (sound_options & OPT_SOUND_LOGOUT)
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
306 play(BuddyLeave, sizeof(BuddyLeave));
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
307 break;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
308 case SEND:
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
309 if (sound_options & OPT_SOUND_SEND)
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
310 play(Send, sizeof(Send));
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
311 break;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
312 case FIRST_RECEIVE:
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
313 if (sound_options & OPT_SOUND_FIRST_RCV)
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
314 play(Receive, sizeof(Receive));
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
315 break;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
316 case RECEIVE:
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
317 if (sound_options & OPT_SOUND_RECV)
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
318 play(Receive, sizeof(Receive));
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
319 break;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
320 case AWAY:
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
321 if (sound_options & OPT_SOUND_WHEN_AWAY)
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
322 play(Receive, sizeof(Receive));
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
323 break;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
324 }
64
b1d7336cba85 [gaim-migrate @ 74]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 63
diff changeset
325 }
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
326
606
eaab8abda2c0 [gaim-migrate @ 616]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 451
diff changeset
327 #ifdef USE_GNOME
64
b1d7336cba85 [gaim-migrate @ 74]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 63
diff changeset
328
82
05077cb276d4 [gaim-migrate @ 92]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 79
diff changeset
329 #include <gnome.h>
451
7b49c67e561c [gaim-migrate @ 461]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 354
diff changeset
330 void play_sound(int sound)
64
b1d7336cba85 [gaim-migrate @ 74]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 63
diff changeset
331 {
b1d7336cba85 [gaim-migrate @ 74]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 63
diff changeset
332
338
9d258a0aa560 [gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 178
diff changeset
333 if (!(sound_options & OPT_SOUND_THROUGH_GNOME)) {
606
eaab8abda2c0 [gaim-migrate @ 616]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 451
diff changeset
334 gnome_play_sound(sound);
338
9d258a0aa560 [gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 178
diff changeset
335 return;
9d258a0aa560 [gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 178
diff changeset
336 }
9d258a0aa560 [gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 178
diff changeset
337
64
b1d7336cba85 [gaim-migrate @ 74]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 63
diff changeset
338 switch(sound) {
b1d7336cba85 [gaim-migrate @ 74]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 63
diff changeset
339 case BUDDY_ARRIVE:
133
e277d5f0c1dd [gaim-migrate @ 143]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 108
diff changeset
340 if ((sound_options & OPT_SOUND_LOGIN) && logins_not_muted)
606
eaab8abda2c0 [gaim-migrate @ 616]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 451
diff changeset
341 gnome_triggers_do("", "program", "gaim", "login", NULL);
64
b1d7336cba85 [gaim-migrate @ 74]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 63
diff changeset
342 break;
b1d7336cba85 [gaim-migrate @ 74]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 63
diff changeset
343 case BUDDY_LEAVE:
b1d7336cba85 [gaim-migrate @ 74]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 63
diff changeset
344 if (sound_options & OPT_SOUND_LOGOUT)
606
eaab8abda2c0 [gaim-migrate @ 616]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 451
diff changeset
345 gnome_triggers_do("", "program", "gaim", "leave", NULL);
64
b1d7336cba85 [gaim-migrate @ 74]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 63
diff changeset
346 break;
b1d7336cba85 [gaim-migrate @ 74]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 63
diff changeset
347 case SEND:
b1d7336cba85 [gaim-migrate @ 74]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 63
diff changeset
348 if (sound_options & OPT_SOUND_SEND)
606
eaab8abda2c0 [gaim-migrate @ 616]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 451
diff changeset
349 gnome_triggers_do("", "program", "gaim", "send", NULL);
64
b1d7336cba85 [gaim-migrate @ 74]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 63
diff changeset
350 break;
b1d7336cba85 [gaim-migrate @ 74]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 63
diff changeset
351 case FIRST_RECEIVE:
b1d7336cba85 [gaim-migrate @ 74]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 63
diff changeset
352 if (sound_options & OPT_SOUND_FIRST_RCV)
606
eaab8abda2c0 [gaim-migrate @ 616]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 451
diff changeset
353 gnome_triggers_do("", "program", "gaim", "recv", NULL);
64
b1d7336cba85 [gaim-migrate @ 74]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 63
diff changeset
354 break;
b1d7336cba85 [gaim-migrate @ 74]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 63
diff changeset
355 case RECEIVE:
b1d7336cba85 [gaim-migrate @ 74]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 63
diff changeset
356 if (sound_options & OPT_SOUND_RECV)
606
eaab8abda2c0 [gaim-migrate @ 616]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 451
diff changeset
357 gnome_triggers_do("", "program", "gaim", "recv", NULL);
64
b1d7336cba85 [gaim-migrate @ 74]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 63
diff changeset
358 break;
b1d7336cba85 [gaim-migrate @ 74]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 63
diff changeset
359 case AWAY:
b1d7336cba85 [gaim-migrate @ 74]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 63
diff changeset
360 if (sound_options & OPT_SOUND_WHEN_AWAY)
606
eaab8abda2c0 [gaim-migrate @ 616]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 451
diff changeset
361 gnome_triggers_do("", "program", "gaim", "recv", NULL);
64
b1d7336cba85 [gaim-migrate @ 74]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 63
diff changeset
362 break;
b1d7336cba85 [gaim-migrate @ 74]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 63
diff changeset
363 }
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
364 }
64
b1d7336cba85 [gaim-migrate @ 74]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 63
diff changeset
365
606
eaab8abda2c0 [gaim-migrate @ 616]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 451
diff changeset
366 #endif /* USE_GNOME */