Mercurial > pidgin
annotate src/sound.c @ 5560:b7319c094153
[gaim-migrate @ 5961]
It compiles now, but if you use it, you won't have any accounts.
committer: Tailor Script <tailor@pidgin.im>
author | Christian Hammond <chipx86@chipx86.com> |
---|---|
date | Fri, 30 May 2003 03:25:39 +0000 |
parents | 7a64114641c3 |
children | 9cd94a5bec8e |
rev | line source |
---|---|
1 | 1 /* |
2 * gaim | |
3 * | |
4562 | 4 * Copyright (C) 1998-1999, Mark Spencer <markster@marko.net> |
4561 | 5 * Copyright (C) 2003, Nathan Walp <faceprint@faceprint.com> |
1 | 6 * |
7 * This program is free software; you can redistribute it and/or modify | |
8 * it under the terms of the GNU General Public License as published by | |
9 * the Free Software Foundation; either version 2 of the License, or | |
10 * (at your option) any later version. | |
11 * | |
12 * This program is distributed in the hope that it will be useful, | |
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 * GNU General Public License for more details. | |
16 * | |
17 * You should have received a copy of the GNU General Public License | |
18 * along with this program; if not, write to the Free Software | |
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
20 * | |
21 */ | |
22 | |
349
b402a23f35df
[gaim-migrate @ 359]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
23 #ifdef HAVE_CONFIG_H |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2048
diff
changeset
|
24 #include <config.h> |
349
b402a23f35df
[gaim-migrate @ 359]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
25 #endif |
1 | 26 #include <stdio.h> |
1057
d50d3abb9eb7
[gaim-migrate @ 1067]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1006
diff
changeset
|
27 #include <stdlib.h> |
1 | 28 #include <string.h> |
3630 | 29 |
30 #ifndef _WIN32 | |
63 | 31 #include <unistd.h> |
3630 | 32 #else |
33 #include <windows.h> | |
34 #include <mmsystem.h> | |
35 #endif | |
36 | |
4592 | 37 #ifdef HAVE_ENDIAN_H |
38 #include <endian.h> | |
39 #endif | |
40 | |
4561 | 41 #ifdef USE_AO |
42 #include <ao/ao.h> | |
43 #include <audiofile.h> | |
44 #endif /* USE_AO */ | |
4581 | 45 #ifdef USE_NAS_AUDIO |
46 #include <audio/audiolib.h> | |
47 #include <audio/soundlib.h> | |
48 #endif /* USE_NAS_AUDIO */ | |
4012 | 49 |
1 | 50 #include "gaim.h" |
4561 | 51 #include "sound.h" |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5281
diff
changeset
|
52 #include "notify.h" |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
53 #include "prefs.h" |
1 | 54 |
4019
e53d9f9969d0
[gaim-migrate @ 4219]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4014
diff
changeset
|
55 #ifdef _WIN32 |
e53d9f9969d0
[gaim-migrate @ 4219]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4014
diff
changeset
|
56 #include "win32dep.h" |
e53d9f9969d0
[gaim-migrate @ 4219]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4014
diff
changeset
|
57 #endif |
e53d9f9969d0
[gaim-migrate @ 4219]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4014
diff
changeset
|
58 |
4561 | 59 struct gaim_sound_event { |
60 char *label; | |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
61 char *pref; |
4561 | 62 char *def; |
63 }; | |
64 | |
65 #ifdef USE_AO | |
4581 | 66 static gboolean ao_initialized=FALSE; |
67 static int ao_driver = -1; | |
4561 | 68 #endif /* USE_AO */ |
69 | |
70 | |
71 static gboolean mute_login_sounds = FALSE; | |
72 static gboolean mute_sounds = FALSE; | |
73 static char *sound_cmd = NULL; | |
3319 | 74 |
4082 | 75 /* description, option bit, default sound file * |
76 * set the option bit to 0 to have it not display in prefs * | |
77 * the order here has to match the defines in gaim.h. * | |
78 * -Robot101 */ | |
4561 | 79 static struct gaim_sound_event sounds[GAIM_NUM_SOUNDS] = { |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
80 {N_("Buddy logs in"), "/gaim/gtk/sound/login", "arrive.wav"}, |
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
81 {N_("Buddy logs out"), "/gaim/gtk/sound/logout", "leave.wav"}, |
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
82 {N_("Message received"), "/gaim/gtk/sound/message_recv", "receive.wav"}, |
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
83 {N_("Message received begins conversation"), "/gaim/gtk/sound/first_message_recv", "receive.wav"}, |
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
84 {N_("Message sent"), "/gaim/gtk/sound/send_im", "send.wav"}, |
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
85 {N_("Person enters chat"), "/gaim/gtk/sound/join_chat", "arrive.wav"}, |
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
86 {N_("Person leaves chat"), "/gaim/gtk/sound/left_chat", "leave.wav"}, |
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
87 {N_("You talk in chat"), "/gaim/gtk/sound/send_chat_msg", "send.wav"}, |
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
88 {N_("Others talk in chat"), "/gaim/gtk/sound/chat_msg_recv", "receive.wav"}, |
3326 | 89 /* this isn't a terminator, it's the buddy pounce default sound event ;-) */ |
4012 | 90 {NULL, 0, "redalert.wav"}, |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
91 {N_("Someone says your name in chat"), "/gaim/gtk/sound/nick_said", "redalert.wav"} |
3060 | 92 }; |
93 | |
4561 | 94 static char *sound_file[GAIM_NUM_SOUNDS]; |
4430 | 95 |
4581 | 96 |
97 #ifdef USE_AO | |
98 static void check_ao_init() | |
4430 | 99 { |
4581 | 100 if(!ao_initialized) { |
5211
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
4878
diff
changeset
|
101 gaim_debug(GAIM_DEBUG_INFO, "sound", |
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
4878
diff
changeset
|
102 "Initializing sound output drivers.\n"); |
4581 | 103 ao_initialize(); |
104 ao_initialized = TRUE; | |
105 } | |
106 } | |
107 #endif /* USE_AO */ | |
4430 | 108 |
4581 | 109 void gaim_sound_change_output_method() { |
110 #ifdef USE_AO | |
111 ao_driver = -1; | |
4430 | 112 |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
113 if (gaim_prefs_get_bool("/core/sound/use_esd") || |
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
114 gaim_prefs_get_bool("/core/sound/use_arts") || |
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
115 gaim_prefs_get_bool("/core/sound/use_sys_default")) { |
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
116 |
4581 | 117 check_ao_init(); |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
118 |
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
119 if (ao_driver == -1 && gaim_prefs_get_bool("/core/sound/use_esd")) |
4581 | 120 ao_driver = ao_driver_id("esd"); |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
121 |
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
122 if (ao_driver == -1 && gaim_prefs_get_bool("/core/sound/use_arts")) |
4581 | 123 ao_driver = ao_driver_id("arts"); |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
124 |
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
125 if (ao_driver == -1) |
4581 | 126 ao_driver = ao_default_driver_id(); |
127 } | |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
128 |
4581 | 129 if(ao_driver != -1) { |
4561 | 130 ao_info *info = ao_driver_info(ao_driver); |
5211
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
4878
diff
changeset
|
131 gaim_debug(GAIM_DEBUG_INFO, "sound", |
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
4878
diff
changeset
|
132 "Sound output driver loaded: %s\n", info->name); |
4430 | 133 } |
4581 | 134 #endif /* USE_AO */ |
135 #ifdef USE_NAS | |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
136 if (gaim_prefs_get_bool("/core/sound/use_nas")) |
5211
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
4878
diff
changeset
|
137 gaim_debug(GAIM_DEBUG_INFO, "sound", |
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
4878
diff
changeset
|
138 "Sound output driver loaded: NAS output\n"); |
4581 | 139 #endif /* USE_NAS */ |
4430 | 140 } |
141 | |
4561 | 142 void gaim_sound_quit() |
4430 | 143 { |
4561 | 144 #ifdef USE_AO |
4581 | 145 if(ao_initialized) |
146 ao_shutdown(); | |
4561 | 147 #endif |
4430 | 148 } |
149 | |
4581 | 150 |
151 #ifdef USE_NAS_AUDIO | |
152 static gboolean play_file_nas(const char *filename) | |
153 { | |
154 AuServer *nas_serv; | |
155 gboolean ret = FALSE; | |
156 | |
157 if((nas_serv = AuOpenServer(NULL, 0, NULL, 0, NULL, NULL))) { | |
158 ret = AuSoundPlaySynchronousFromFile(nas_serv, filename, 100); | |
159 AuCloseServer(nas_serv); | |
160 } | |
161 | |
162 return ret; | |
163 } | |
164 | |
165 #endif /* USE_NAS_AUDIO */ | |
166 | |
4561 | 167 void gaim_sound_play_file(char *filename) |
4430 | 168 { |
4581 | 169 #if defined(USE_NAS_AUDIO) || defined(USE_AO) |
4561 | 170 pid_t pid; |
4581 | 171 #ifdef USE_AO |
172 AFfilehandle file; | |
173 #endif | |
174 #endif | |
4430 | 175 |
4561 | 176 if (mute_sounds) |
177 return; | |
4430 | 178 |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
179 if (awaymessage && !gaim_prefs_get_bool("/core/sound/while_away")) |
3901 | 180 return; /* check here in case a buddy pounce plays a file while away */ |
4561 | 181 |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
182 if (gaim_prefs_get_bool("/core/sound/use_beep")) { |
3004 | 183 gdk_beep(); |
184 return; | |
185 } | |
186 | |
4561 | 187 if (!g_file_test(filename, G_FILE_TEST_EXISTS)) { |
5281 | 188 char *tmp = g_strdup_printf(_("Unable to play sound because the chosen file (%s) does not exist."), filename); |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5281
diff
changeset
|
189 gaim_notify_error(NULL, NULL, tmp, NULL); |
4561 | 190 g_free(tmp); |
191 return; | |
3060 | 192 } |
4561 | 193 |
4430 | 194 #ifndef _WIN32 |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
195 if (gaim_prefs_get_bool("/core/sound/use_custom")) { |
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
196 const char *sound_cmd; |
4561 | 197 char *command; |
198 GError *error = NULL; | |
199 | |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
200 sound_cmd = gaim_prefs_get_string("/core/sound/command"); |
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
201 |
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
202 if (!sound_cmd || *sound_cmd == '\0') { |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5281
diff
changeset
|
203 gaim_notify_error(NULL, NULL, |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5281
diff
changeset
|
204 _("Unable to play sound because the " |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5281
diff
changeset
|
205 "'Command' sound method has been chosen, " |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5281
diff
changeset
|
206 "but no command has been set."), NULL); |
4561 | 207 return; |
208 } | |
209 | |
210 command = g_strdup_printf(sound_cmd, filename); | |
211 | |
212 if(!g_spawn_command_line_async(command, &error)) { | |
213 char *tmp = g_strdup_printf(_("Unable to play sound because the configured sound command could not be launched: %s"), error->message); | |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5281
diff
changeset
|
214 gaim_notify_error(NULL, NULL, tmp, NULL); |
4561 | 215 g_free(tmp); |
216 g_error_free(error); | |
217 } | |
218 | |
219 g_free(command); | |
220 return; | |
221 } | |
4581 | 222 #if defined(USE_NAS_AUDIO) || defined(USE_AO) |
1006
0a4d0ed65e17
[gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
899
diff
changeset
|
223 pid = fork(); |
0a4d0ed65e17
[gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
899
diff
changeset
|
224 if (pid < 0) |
0a4d0ed65e17
[gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
899
diff
changeset
|
225 return; |
0a4d0ed65e17
[gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
899
diff
changeset
|
226 else if (pid == 0) { |
4581 | 227 #ifdef USE_NAS_AUDIO |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
228 if (gaim_prefs_get_bool("/core/sound/use_nas")) { |
4581 | 229 if (play_file_nas(filename)) |
230 _exit(0); | |
231 } | |
232 #endif /* USE_NAS_AUDIO */ | |
233 | |
234 #ifdef USE_AO | |
235 file = afOpenFile(filename, "rb", NULL); | |
4561 | 236 if(file) { |
237 ao_device *device; | |
238 ao_sample_format format; | |
239 int in_fmt; | |
240 int bytes_per_frame; | |
4429 | 241 |
4561 | 242 format.rate = afGetRate(file, AF_DEFAULT_TRACK); |
243 format.channels = afGetChannels(file, AF_DEFAULT_TRACK); | |
244 afGetSampleFormat(file, AF_DEFAULT_TRACK, &in_fmt, | |
245 &format.bits); | |
246 | |
4878 | 247 /* XXX: libao doesn't seem to like 8-bit sounds, so we'll |
248 * let libaudiofile make them a bit better for us */ | |
249 if(format.bits == 8) | |
250 format.bits = 16; | |
251 | |
4561 | 252 afSetVirtualSampleFormat(file, AF_DEFAULT_TRACK, |
253 AF_SAMPFMT_TWOSCOMP, format.bits); | |
4429 | 254 |
4592 | 255 #if __BYTE_ORDER == __BIG_ENDIAN |
256 format.byte_format = AO_FMT_BIG; | |
257 afSetVirtualByteOrder(file, AF_DEFAULT_TRACK, | |
258 AF_BYTEORDER_BIGENDIAN); | |
259 #elif __BYTE_ORDER == __LITTLE_ENDIAN | |
260 format.byte_format = AO_FMT_LITTLE; | |
261 afSetVirtualByteOrder(file, AF_DEFAULT_TRACK, | |
262 AF_BYTEORDER_LITTLEENDIAN); | |
263 #endif | |
4561 | 264 |
265 bytes_per_frame = format.bits * format.channels / 8; | |
266 | |
267 device = ao_open_live(ao_driver, &format, NULL); | |
268 | |
269 if(device) { | |
270 int frames_read; | |
271 char buf[4096]; | |
272 int buf_frames = sizeof(buf) / bytes_per_frame; | |
273 | |
274 while((frames_read = afReadFrames(file, AF_DEFAULT_TRACK, | |
275 buf, buf_frames))) { | |
276 if(!ao_play(device, buf, frames_read * bytes_per_frame)) | |
277 break; | |
278 } | |
279 ao_close(device); | |
280 } | |
281 afCloseFile(file); | |
4430 | 282 } |
4581 | 283 ao_shutdown(); |
284 #endif /* USE_AO */ | |
1006
0a4d0ed65e17
[gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
899
diff
changeset
|
285 _exit(0); |
0a4d0ed65e17
[gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
899
diff
changeset
|
286 } |
4581 | 287 #else /* USE_NAS_AUDIO || USE_AO */ |
4561 | 288 gdk_beep(); |
289 return; | |
4581 | 290 #endif /* USE_NAS_AUDIO || USE_AO */ |
3630 | 291 #else /* _WIN32 */ |
5211
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
4878
diff
changeset
|
292 gaim_debug(GAIM_DEBUG_INFO, "sound", "Playing %s\n", filename); |
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
4878
diff
changeset
|
293 |
3630 | 294 if (!PlaySound(filename, 0, SND_ASYNC | SND_FILENAME)) |
5211
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
4878
diff
changeset
|
295 gaim_debug(GAIM_DEBUG_ERROR, "sound", "Error playing sound.\n"); |
4561 | 296 #endif /* _WIN32 */ |
1006
0a4d0ed65e17
[gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
899
diff
changeset
|
297 } |
0a4d0ed65e17
[gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
899
diff
changeset
|
298 |
4561 | 299 void gaim_sound_play_event(GaimSoundEventID event) |
1 | 300 { |
4561 | 301 if ((event == GAIM_SOUND_BUDDY_ARRIVE) && mute_login_sounds) |
3060 | 302 return; |
303 | |
4561 | 304 if (event >= GAIM_NUM_SOUNDS) { |
5211
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
4878
diff
changeset
|
305 gaim_debug(GAIM_DEBUG_MISC, "sound", |
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
4878
diff
changeset
|
306 "got request for unknown sound: %d\n", event); |
3060 | 307 return; |
308 } | |
309 | |
310 /* check NULL for sounds that don't have an option, ie buddy pounce */ | |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
311 if (sounds[event].pref == NULL || gaim_prefs_get_bool(sounds[event].pref)) { |
4561 | 312 if (sound_file[event]) { |
313 gaim_sound_play_file(sound_file[event]); | |
3060 | 314 } else { |
4004 | 315 gchar *filename = NULL; |
316 | |
4561 | 317 filename = g_build_filename(DATADIR, "sounds", "gaim", sounds[event].def, NULL); |
318 gaim_sound_play_file(filename); | |
4004 | 319 g_free(filename); |
1006
0a4d0ed65e17
[gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
899
diff
changeset
|
320 } |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1235
diff
changeset
|
321 } |
64 | 322 } |
4561 | 323 |
324 void gaim_sound_set_mute(gboolean mute) | |
325 { | |
326 mute_sounds = mute; | |
327 } | |
328 | |
329 gboolean gaim_sound_get_mute() | |
330 { | |
331 return mute_sounds; | |
332 } | |
333 | |
334 void gaim_sound_set_login_mute(gboolean mute) | |
335 { | |
336 mute_login_sounds = mute; | |
337 } | |
338 | |
339 void gaim_sound_set_event_file(GaimSoundEventID event, const char *filename) | |
340 { | |
341 if(event >= GAIM_NUM_SOUNDS) | |
342 return; | |
343 | |
344 if(sound_file[event]) | |
345 g_free(sound_file[event]); | |
346 | |
347 sound_file[event] = g_strdup(filename); | |
348 } | |
349 | |
350 | |
351 char *gaim_sound_get_event_file(GaimSoundEventID event) | |
352 { | |
353 if(event >= GAIM_NUM_SOUNDS) | |
354 return NULL; | |
355 | |
356 return sound_file[event]; | |
357 } | |
358 | |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
359 const char *gaim_sound_get_event_option(GaimSoundEventID event) |
4561 | 360 { |
361 if(event >= GAIM_NUM_SOUNDS) | |
362 return 0; | |
363 | |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
364 return sounds[event].pref; |
4561 | 365 } |
366 | |
367 char *gaim_sound_get_event_label(GaimSoundEventID event) | |
368 { | |
369 if(event >= GAIM_NUM_SOUNDS) | |
370 return NULL; | |
371 | |
372 return sounds[event].label; | |
373 } | |
374 | |
375 | |
376 void gaim_sound_set_command(const char *cmd) | |
377 { | |
378 if(sound_cmd) | |
379 g_free(sound_cmd); | |
380 if(strlen(cmd) > 0) | |
381 sound_cmd = g_strdup(cmd); | |
382 else | |
383 sound_cmd = NULL; | |
384 } | |
385 | |
386 char *gaim_sound_get_command() | |
387 { | |
388 return sound_cmd; | |
389 } | |
390 |