annotate src/sound.c @ 4874:f98467b35b95

[gaim-migrate @ 5204] plug a few more memleaks committer: Tailor Script <tailor@pidgin.im>
author Nathan Walp <nwalp@pidgin.im>
date Sun, 23 Mar 2003 18:47:33 +0000
parents b69bbf9b1044
children 77b04219f3e2
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 *
4562
2c8372d4fb2a [gaim-migrate @ 4843]
Nathan Walp <nwalp@pidgin.im>
parents: 4561
diff changeset
4 * Copyright (C) 1998-1999, Mark Spencer <markster@marko.net>
4561
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
5 * Copyright (C) 2003, Nathan Walp <faceprint@faceprint.com>
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
6 *
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
7 * This program is free software; you can redistribute it and/or modify
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
8 * 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
9 * the Free Software Foundation; either version 2 of the License, or
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
10 * (at your option) any later version.
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
11 *
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
12 * This program is distributed in the hope that it will be useful,
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
15 * GNU General Public License for more details.
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
16 *
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
17 * You should have received a copy of the GNU General Public License
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
18 * along with this program; if not, write to the Free Software
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
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 */
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
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
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
26 #include <stdio.h>
1057
d50d3abb9eb7 [gaim-migrate @ 1067]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1006
diff changeset
27 #include <stdlib.h>
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
28 #include <string.h>
3630
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3367
diff changeset
29
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3367
diff changeset
30 #ifndef _WIN32
63
12894b62d206 [gaim-migrate @ 73]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
31 #include <unistd.h>
3630
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3367
diff changeset
32 #else
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3367
diff changeset
33 #include <windows.h>
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3367
diff changeset
34 #include <mmsystem.h>
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3367
diff changeset
35 #endif
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3367
diff changeset
36
4592
b69bbf9b1044 [gaim-migrate @ 4876]
Nathan Walp <nwalp@pidgin.im>
parents: 4581
diff changeset
37 #ifdef HAVE_ENDIAN_H
b69bbf9b1044 [gaim-migrate @ 4876]
Nathan Walp <nwalp@pidgin.im>
parents: 4581
diff changeset
38 #include <endian.h>
b69bbf9b1044 [gaim-migrate @ 4876]
Nathan Walp <nwalp@pidgin.im>
parents: 4581
diff changeset
39 #endif
b69bbf9b1044 [gaim-migrate @ 4876]
Nathan Walp <nwalp@pidgin.im>
parents: 4581
diff changeset
40
4561
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
41 #ifdef USE_AO
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
42 #include <ao/ao.h>
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
43 #include <audiofile.h>
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
44 #endif /* USE_AO */
4581
4b1e24835bbf [gaim-migrate @ 4864]
Nathan Walp <nwalp@pidgin.im>
parents: 4579
diff changeset
45 #ifdef USE_NAS_AUDIO
4b1e24835bbf [gaim-migrate @ 4864]
Nathan Walp <nwalp@pidgin.im>
parents: 4579
diff changeset
46 #include <audio/audiolib.h>
4b1e24835bbf [gaim-migrate @ 4864]
Nathan Walp <nwalp@pidgin.im>
parents: 4579
diff changeset
47 #include <audio/soundlib.h>
4b1e24835bbf [gaim-migrate @ 4864]
Nathan Walp <nwalp@pidgin.im>
parents: 4579
diff changeset
48 #endif /* USE_NAS_AUDIO */
4012
ab6c48a07fd6 [gaim-migrate @ 4212]
Sean Egan <seanegan@gmail.com>
parents: 4010
diff changeset
49
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
50 #include "gaim.h"
4561
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
51 #include "sound.h"
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
52
4019
e53d9f9969d0 [gaim-migrate @ 4219]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4014
diff changeset
53 #ifdef _WIN32
e53d9f9969d0 [gaim-migrate @ 4219]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4014
diff changeset
54 #include "win32dep.h"
e53d9f9969d0 [gaim-migrate @ 4219]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4014
diff changeset
55 #endif
e53d9f9969d0 [gaim-migrate @ 4219]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4014
diff changeset
56
4561
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
57 struct gaim_sound_event {
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
58 char *label;
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
59 guint opt;
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
60 char *def;
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
61 };
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
62
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
63 #ifdef USE_AO
4581
4b1e24835bbf [gaim-migrate @ 4864]
Nathan Walp <nwalp@pidgin.im>
parents: 4579
diff changeset
64 static gboolean ao_initialized=FALSE;
4b1e24835bbf [gaim-migrate @ 4864]
Nathan Walp <nwalp@pidgin.im>
parents: 4579
diff changeset
65 static int ao_driver = -1;
4561
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
66 #endif /* USE_AO */
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
67
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
68
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
69 static gboolean mute_login_sounds = FALSE;
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
70 static gboolean mute_sounds = FALSE;
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
71 static char *sound_cmd = NULL;
3319
3a05fcb133c4 [gaim-migrate @ 3337]
Sean Egan <seanegan@gmail.com>
parents: 3284
diff changeset
72
4082
4b04ecb3eb97 [gaim-migrate @ 4297]
Luke Schierer <lschiere@pidgin.im>
parents: 4019
diff changeset
73 /* description, option bit, default sound file *
4b04ecb3eb97 [gaim-migrate @ 4297]
Luke Schierer <lschiere@pidgin.im>
parents: 4019
diff changeset
74 * set the option bit to 0 to have it not display in prefs *
4b04ecb3eb97 [gaim-migrate @ 4297]
Luke Schierer <lschiere@pidgin.im>
parents: 4019
diff changeset
75 * the order here has to match the defines in gaim.h. *
4b04ecb3eb97 [gaim-migrate @ 4297]
Luke Schierer <lschiere@pidgin.im>
parents: 4019
diff changeset
76 * -Robot101 */
4561
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
77 static struct gaim_sound_event sounds[GAIM_NUM_SOUNDS] = {
4013
73853a0a1a77 [gaim-migrate @ 4213]
Sean Egan <seanegan@gmail.com>
parents: 4012
diff changeset
78 {N_("Buddy logs in"), OPT_SOUND_LOGIN, "arrive.wav"},
73853a0a1a77 [gaim-migrate @ 4213]
Sean Egan <seanegan@gmail.com>
parents: 4012
diff changeset
79 {N_("Buddy logs out"), OPT_SOUND_LOGOUT, "leave.wav"},
4012
ab6c48a07fd6 [gaim-migrate @ 4212]
Sean Egan <seanegan@gmail.com>
parents: 4010
diff changeset
80 {N_("Message received"), OPT_SOUND_RECV, "receive.wav"},
ab6c48a07fd6 [gaim-migrate @ 4212]
Sean Egan <seanegan@gmail.com>
parents: 4010
diff changeset
81 {N_("Message received begins conversation"), OPT_SOUND_FIRST_RCV, "receive.wav"},
ab6c48a07fd6 [gaim-migrate @ 4212]
Sean Egan <seanegan@gmail.com>
parents: 4010
diff changeset
82 {N_("Message sent"), OPT_SOUND_SEND, "send.wav"},
4013
73853a0a1a77 [gaim-migrate @ 4213]
Sean Egan <seanegan@gmail.com>
parents: 4012
diff changeset
83 {N_("Person enters chat"), OPT_SOUND_CHAT_JOIN, "arrive.wav"},
73853a0a1a77 [gaim-migrate @ 4213]
Sean Egan <seanegan@gmail.com>
parents: 4012
diff changeset
84 {N_("Person leaves chat"), OPT_SOUND_CHAT_PART, "leave.wav"},
4012
ab6c48a07fd6 [gaim-migrate @ 4212]
Sean Egan <seanegan@gmail.com>
parents: 4010
diff changeset
85 {N_("You talk in chat"), OPT_SOUND_CHAT_YOU_SAY, "send.wav"},
ab6c48a07fd6 [gaim-migrate @ 4212]
Sean Egan <seanegan@gmail.com>
parents: 4010
diff changeset
86 {N_("Others talk in chat"), OPT_SOUND_CHAT_SAY, "receive.wav"},
3326
03daf01a8000 [gaim-migrate @ 3344]
Jim Seymour <jseymour>
parents: 3319
diff changeset
87 /* this isn't a terminator, it's the buddy pounce default sound event ;-) */
4012
ab6c48a07fd6 [gaim-migrate @ 4212]
Sean Egan <seanegan@gmail.com>
parents: 4010
diff changeset
88 {NULL, 0, "redalert.wav"},
ab6c48a07fd6 [gaim-migrate @ 4212]
Sean Egan <seanegan@gmail.com>
parents: 4010
diff changeset
89 {N_("Someone says your name in chat"), OPT_SOUND_CHAT_NICK, "redalert.wav"}
3060
4f2f12bf4408 [gaim-migrate @ 3074]
Sean Egan <seanegan@gmail.com>
parents: 3025
diff changeset
90 };
4f2f12bf4408 [gaim-migrate @ 3074]
Sean Egan <seanegan@gmail.com>
parents: 3025
diff changeset
91
4561
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
92 static char *sound_file[GAIM_NUM_SOUNDS];
4430
801830dec409 [gaim-migrate @ 4705]
Luke Schierer <lschiere@pidgin.im>
parents: 4429
diff changeset
93
4581
4b1e24835bbf [gaim-migrate @ 4864]
Nathan Walp <nwalp@pidgin.im>
parents: 4579
diff changeset
94
4b1e24835bbf [gaim-migrate @ 4864]
Nathan Walp <nwalp@pidgin.im>
parents: 4579
diff changeset
95 #ifdef USE_AO
4b1e24835bbf [gaim-migrate @ 4864]
Nathan Walp <nwalp@pidgin.im>
parents: 4579
diff changeset
96 static void check_ao_init()
4430
801830dec409 [gaim-migrate @ 4705]
Luke Schierer <lschiere@pidgin.im>
parents: 4429
diff changeset
97 {
4581
4b1e24835bbf [gaim-migrate @ 4864]
Nathan Walp <nwalp@pidgin.im>
parents: 4579
diff changeset
98 if(!ao_initialized) {
4b1e24835bbf [gaim-migrate @ 4864]
Nathan Walp <nwalp@pidgin.im>
parents: 4579
diff changeset
99 debug_printf("Initializing sound ouput drivers.\n");
4b1e24835bbf [gaim-migrate @ 4864]
Nathan Walp <nwalp@pidgin.im>
parents: 4579
diff changeset
100 ao_initialize();
4b1e24835bbf [gaim-migrate @ 4864]
Nathan Walp <nwalp@pidgin.im>
parents: 4579
diff changeset
101 ao_initialized = TRUE;
4b1e24835bbf [gaim-migrate @ 4864]
Nathan Walp <nwalp@pidgin.im>
parents: 4579
diff changeset
102 }
4b1e24835bbf [gaim-migrate @ 4864]
Nathan Walp <nwalp@pidgin.im>
parents: 4579
diff changeset
103 }
4b1e24835bbf [gaim-migrate @ 4864]
Nathan Walp <nwalp@pidgin.im>
parents: 4579
diff changeset
104 #endif /* USE_AO */
4430
801830dec409 [gaim-migrate @ 4705]
Luke Schierer <lschiere@pidgin.im>
parents: 4429
diff changeset
105
4581
4b1e24835bbf [gaim-migrate @ 4864]
Nathan Walp <nwalp@pidgin.im>
parents: 4579
diff changeset
106 void gaim_sound_change_output_method() {
4b1e24835bbf [gaim-migrate @ 4864]
Nathan Walp <nwalp@pidgin.im>
parents: 4579
diff changeset
107 #ifdef USE_AO
4b1e24835bbf [gaim-migrate @ 4864]
Nathan Walp <nwalp@pidgin.im>
parents: 4579
diff changeset
108 ao_driver = -1;
4430
801830dec409 [gaim-migrate @ 4705]
Luke Schierer <lschiere@pidgin.im>
parents: 4429
diff changeset
109
4581
4b1e24835bbf [gaim-migrate @ 4864]
Nathan Walp <nwalp@pidgin.im>
parents: 4579
diff changeset
110 if ((sound_options & OPT_SOUND_ESD) || (sound_options & OPT_SOUND_ARTS) ||
4b1e24835bbf [gaim-migrate @ 4864]
Nathan Walp <nwalp@pidgin.im>
parents: 4579
diff changeset
111 (sound_options & OPT_SOUND_NORMAL)) {
4b1e24835bbf [gaim-migrate @ 4864]
Nathan Walp <nwalp@pidgin.im>
parents: 4579
diff changeset
112 check_ao_init();
4b1e24835bbf [gaim-migrate @ 4864]
Nathan Walp <nwalp@pidgin.im>
parents: 4579
diff changeset
113 if (ao_driver == -1 && (sound_options & OPT_SOUND_ESD)) {
4b1e24835bbf [gaim-migrate @ 4864]
Nathan Walp <nwalp@pidgin.im>
parents: 4579
diff changeset
114 ao_driver = ao_driver_id("esd");
4b1e24835bbf [gaim-migrate @ 4864]
Nathan Walp <nwalp@pidgin.im>
parents: 4579
diff changeset
115 }
4b1e24835bbf [gaim-migrate @ 4864]
Nathan Walp <nwalp@pidgin.im>
parents: 4579
diff changeset
116 if(ao_driver == -1 && (sound_options & OPT_SOUND_ARTS)) {
4b1e24835bbf [gaim-migrate @ 4864]
Nathan Walp <nwalp@pidgin.im>
parents: 4579
diff changeset
117 ao_driver = ao_driver_id("arts");
4b1e24835bbf [gaim-migrate @ 4864]
Nathan Walp <nwalp@pidgin.im>
parents: 4579
diff changeset
118 }
4b1e24835bbf [gaim-migrate @ 4864]
Nathan Walp <nwalp@pidgin.im>
parents: 4579
diff changeset
119 if (ao_driver == -1) {
4b1e24835bbf [gaim-migrate @ 4864]
Nathan Walp <nwalp@pidgin.im>
parents: 4579
diff changeset
120 ao_driver = ao_default_driver_id();
4b1e24835bbf [gaim-migrate @ 4864]
Nathan Walp <nwalp@pidgin.im>
parents: 4579
diff changeset
121 }
4b1e24835bbf [gaim-migrate @ 4864]
Nathan Walp <nwalp@pidgin.im>
parents: 4579
diff changeset
122 }
4b1e24835bbf [gaim-migrate @ 4864]
Nathan Walp <nwalp@pidgin.im>
parents: 4579
diff changeset
123 if(ao_driver != -1) {
4561
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
124 ao_info *info = ao_driver_info(ao_driver);
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
125 debug_printf("Sound output driver loaded: %s\n", info->name);
4430
801830dec409 [gaim-migrate @ 4705]
Luke Schierer <lschiere@pidgin.im>
parents: 4429
diff changeset
126 }
4581
4b1e24835bbf [gaim-migrate @ 4864]
Nathan Walp <nwalp@pidgin.im>
parents: 4579
diff changeset
127 #endif /* USE_AO */
4b1e24835bbf [gaim-migrate @ 4864]
Nathan Walp <nwalp@pidgin.im>
parents: 4579
diff changeset
128 #ifdef USE_NAS
4b1e24835bbf [gaim-migrate @ 4864]
Nathan Walp <nwalp@pidgin.im>
parents: 4579
diff changeset
129 if((sound_options & OPT_SOUND_NAS))
4b1e24835bbf [gaim-migrate @ 4864]
Nathan Walp <nwalp@pidgin.im>
parents: 4579
diff changeset
130 debug_printf("Sound output driver loaded: NAS output\n");
4b1e24835bbf [gaim-migrate @ 4864]
Nathan Walp <nwalp@pidgin.im>
parents: 4579
diff changeset
131 #endif /* USE_NAS */
4430
801830dec409 [gaim-migrate @ 4705]
Luke Schierer <lschiere@pidgin.im>
parents: 4429
diff changeset
132 }
801830dec409 [gaim-migrate @ 4705]
Luke Schierer <lschiere@pidgin.im>
parents: 4429
diff changeset
133
4561
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
134 void gaim_sound_quit()
4430
801830dec409 [gaim-migrate @ 4705]
Luke Schierer <lschiere@pidgin.im>
parents: 4429
diff changeset
135 {
4561
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
136 #ifdef USE_AO
4581
4b1e24835bbf [gaim-migrate @ 4864]
Nathan Walp <nwalp@pidgin.im>
parents: 4579
diff changeset
137 if(ao_initialized)
4b1e24835bbf [gaim-migrate @ 4864]
Nathan Walp <nwalp@pidgin.im>
parents: 4579
diff changeset
138 ao_shutdown();
4561
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
139 #endif
4430
801830dec409 [gaim-migrate @ 4705]
Luke Schierer <lschiere@pidgin.im>
parents: 4429
diff changeset
140 }
801830dec409 [gaim-migrate @ 4705]
Luke Schierer <lschiere@pidgin.im>
parents: 4429
diff changeset
141
4581
4b1e24835bbf [gaim-migrate @ 4864]
Nathan Walp <nwalp@pidgin.im>
parents: 4579
diff changeset
142
4b1e24835bbf [gaim-migrate @ 4864]
Nathan Walp <nwalp@pidgin.im>
parents: 4579
diff changeset
143 #ifdef USE_NAS_AUDIO
4b1e24835bbf [gaim-migrate @ 4864]
Nathan Walp <nwalp@pidgin.im>
parents: 4579
diff changeset
144 static gboolean play_file_nas(const char *filename)
4b1e24835bbf [gaim-migrate @ 4864]
Nathan Walp <nwalp@pidgin.im>
parents: 4579
diff changeset
145 {
4b1e24835bbf [gaim-migrate @ 4864]
Nathan Walp <nwalp@pidgin.im>
parents: 4579
diff changeset
146 AuServer *nas_serv;
4b1e24835bbf [gaim-migrate @ 4864]
Nathan Walp <nwalp@pidgin.im>
parents: 4579
diff changeset
147 gboolean ret = FALSE;
4b1e24835bbf [gaim-migrate @ 4864]
Nathan Walp <nwalp@pidgin.im>
parents: 4579
diff changeset
148
4b1e24835bbf [gaim-migrate @ 4864]
Nathan Walp <nwalp@pidgin.im>
parents: 4579
diff changeset
149 if((nas_serv = AuOpenServer(NULL, 0, NULL, 0, NULL, NULL))) {
4b1e24835bbf [gaim-migrate @ 4864]
Nathan Walp <nwalp@pidgin.im>
parents: 4579
diff changeset
150 ret = AuSoundPlaySynchronousFromFile(nas_serv, filename, 100);
4b1e24835bbf [gaim-migrate @ 4864]
Nathan Walp <nwalp@pidgin.im>
parents: 4579
diff changeset
151 AuCloseServer(nas_serv);
4b1e24835bbf [gaim-migrate @ 4864]
Nathan Walp <nwalp@pidgin.im>
parents: 4579
diff changeset
152 }
4b1e24835bbf [gaim-migrate @ 4864]
Nathan Walp <nwalp@pidgin.im>
parents: 4579
diff changeset
153
4b1e24835bbf [gaim-migrate @ 4864]
Nathan Walp <nwalp@pidgin.im>
parents: 4579
diff changeset
154 return ret;
4b1e24835bbf [gaim-migrate @ 4864]
Nathan Walp <nwalp@pidgin.im>
parents: 4579
diff changeset
155 }
4b1e24835bbf [gaim-migrate @ 4864]
Nathan Walp <nwalp@pidgin.im>
parents: 4579
diff changeset
156
4b1e24835bbf [gaim-migrate @ 4864]
Nathan Walp <nwalp@pidgin.im>
parents: 4579
diff changeset
157 #endif /* USE_NAS_AUDIO */
4b1e24835bbf [gaim-migrate @ 4864]
Nathan Walp <nwalp@pidgin.im>
parents: 4579
diff changeset
158
4561
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
159 void gaim_sound_play_file(char *filename)
4430
801830dec409 [gaim-migrate @ 4705]
Luke Schierer <lschiere@pidgin.im>
parents: 4429
diff changeset
160 {
4581
4b1e24835bbf [gaim-migrate @ 4864]
Nathan Walp <nwalp@pidgin.im>
parents: 4579
diff changeset
161 #if defined(USE_NAS_AUDIO) || defined(USE_AO)
4561
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
162 pid_t pid;
4581
4b1e24835bbf [gaim-migrate @ 4864]
Nathan Walp <nwalp@pidgin.im>
parents: 4579
diff changeset
163 #ifdef USE_AO
4b1e24835bbf [gaim-migrate @ 4864]
Nathan Walp <nwalp@pidgin.im>
parents: 4579
diff changeset
164 AFfilehandle file;
4b1e24835bbf [gaim-migrate @ 4864]
Nathan Walp <nwalp@pidgin.im>
parents: 4579
diff changeset
165 #endif
4b1e24835bbf [gaim-migrate @ 4864]
Nathan Walp <nwalp@pidgin.im>
parents: 4579
diff changeset
166 #endif
4430
801830dec409 [gaim-migrate @ 4705]
Luke Schierer <lschiere@pidgin.im>
parents: 4429
diff changeset
167
4561
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
168 if (mute_sounds)
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
169 return;
4430
801830dec409 [gaim-migrate @ 4705]
Luke Schierer <lschiere@pidgin.im>
parents: 4429
diff changeset
170
3901
7740c891537e [gaim-migrate @ 4054]
Luke Schierer <lschiere@pidgin.im>
parents: 3630
diff changeset
171 if (awaymessage && !(sound_options & OPT_SOUND_WHEN_AWAY))
7740c891537e [gaim-migrate @ 4054]
Luke Schierer <lschiere@pidgin.im>
parents: 3630
diff changeset
172 return; /* check here in case a buddy pounce plays a file while away */
4561
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
173
3004
bfd2b1ef907c [gaim-migrate @ 3017]
Sean Egan <seanegan@gmail.com>
parents: 2995
diff changeset
174 if (sound_options & OPT_SOUND_BEEP) {
bfd2b1ef907c [gaim-migrate @ 3017]
Sean Egan <seanegan@gmail.com>
parents: 2995
diff changeset
175 gdk_beep();
bfd2b1ef907c [gaim-migrate @ 3017]
Sean Egan <seanegan@gmail.com>
parents: 2995
diff changeset
176 return;
bfd2b1ef907c [gaim-migrate @ 3017]
Sean Egan <seanegan@gmail.com>
parents: 2995
diff changeset
177 }
bfd2b1ef907c [gaim-migrate @ 3017]
Sean Egan <seanegan@gmail.com>
parents: 2995
diff changeset
178
4561
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
179 if (!g_file_test(filename, G_FILE_TEST_EXISTS)) {
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
180 char *tmp = g_strdup_printf(_("Unable to play sound because the chosen filename (%s) does not exist."), filename);
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
181 do_error_dialog(tmp, NULL, GAIM_ERROR);
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
182 g_free(tmp);
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
183 return;
3060
4f2f12bf4408 [gaim-migrate @ 3074]
Sean Egan <seanegan@gmail.com>
parents: 3025
diff changeset
184 }
4561
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
185
4430
801830dec409 [gaim-migrate @ 4705]
Luke Schierer <lschiere@pidgin.im>
parents: 4429
diff changeset
186 #ifndef _WIN32
4561
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
187 if ((sound_options & OPT_SOUND_CMD)) {
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
188 char *command;
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
189 GError *error = NULL;
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
190
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
191 if(!sound_cmd) {
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
192 do_error_dialog(_("Unable to play sound because the 'Command' sound method has been chosen, but no command has been set."), NULL, GAIM_ERROR);
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
193 return;
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
194 }
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
195
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
196 command = g_strdup_printf(sound_cmd, filename);
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
197
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
198 if(!g_spawn_command_line_async(command, &error)) {
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
199 char *tmp = g_strdup_printf(_("Unable to play sound because the configured sound command could not be launched: %s"), error->message);
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
200 do_error_dialog(tmp, NULL, GAIM_ERROR);
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
201 g_free(tmp);
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
202 g_error_free(error);
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
203 }
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
204
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
205 g_free(command);
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
206 return;
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
207 }
4581
4b1e24835bbf [gaim-migrate @ 4864]
Nathan Walp <nwalp@pidgin.im>
parents: 4579
diff changeset
208 #if defined(USE_NAS_AUDIO) || defined(USE_AO)
1006
0a4d0ed65e17 [gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 899
diff changeset
209 pid = fork();
0a4d0ed65e17 [gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 899
diff changeset
210 if (pid < 0)
0a4d0ed65e17 [gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 899
diff changeset
211 return;
0a4d0ed65e17 [gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 899
diff changeset
212 else if (pid == 0) {
4581
4b1e24835bbf [gaim-migrate @ 4864]
Nathan Walp <nwalp@pidgin.im>
parents: 4579
diff changeset
213 #ifdef USE_NAS_AUDIO
4b1e24835bbf [gaim-migrate @ 4864]
Nathan Walp <nwalp@pidgin.im>
parents: 4579
diff changeset
214 if ((sound_options & OPT_SOUND_NAS)) {
4b1e24835bbf [gaim-migrate @ 4864]
Nathan Walp <nwalp@pidgin.im>
parents: 4579
diff changeset
215 if (play_file_nas(filename))
4b1e24835bbf [gaim-migrate @ 4864]
Nathan Walp <nwalp@pidgin.im>
parents: 4579
diff changeset
216 _exit(0);
4b1e24835bbf [gaim-migrate @ 4864]
Nathan Walp <nwalp@pidgin.im>
parents: 4579
diff changeset
217 }
4b1e24835bbf [gaim-migrate @ 4864]
Nathan Walp <nwalp@pidgin.im>
parents: 4579
diff changeset
218 #endif /* USE_NAS_AUDIO */
4b1e24835bbf [gaim-migrate @ 4864]
Nathan Walp <nwalp@pidgin.im>
parents: 4579
diff changeset
219
4b1e24835bbf [gaim-migrate @ 4864]
Nathan Walp <nwalp@pidgin.im>
parents: 4579
diff changeset
220 #ifdef USE_AO
4b1e24835bbf [gaim-migrate @ 4864]
Nathan Walp <nwalp@pidgin.im>
parents: 4579
diff changeset
221 file = afOpenFile(filename, "rb", NULL);
4561
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
222 if(file) {
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
223 ao_device *device;
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
224 ao_sample_format format;
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
225 int in_fmt;
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
226 int bytes_per_frame;
4429
bf770f11132b [gaim-migrate @ 4704]
Luke Schierer <lschiere@pidgin.im>
parents: 4082
diff changeset
227
4561
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
228 format.rate = afGetRate(file, AF_DEFAULT_TRACK);
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
229 format.channels = afGetChannels(file, AF_DEFAULT_TRACK);
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
230 afGetSampleFormat(file, AF_DEFAULT_TRACK, &in_fmt,
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
231 &format.bits);
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
232
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
233 afSetVirtualSampleFormat(file, AF_DEFAULT_TRACK,
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
234 AF_SAMPFMT_TWOSCOMP, format.bits);
4429
bf770f11132b [gaim-migrate @ 4704]
Luke Schierer <lschiere@pidgin.im>
parents: 4082
diff changeset
235
4592
b69bbf9b1044 [gaim-migrate @ 4876]
Nathan Walp <nwalp@pidgin.im>
parents: 4581
diff changeset
236 #if __BYTE_ORDER == __BIG_ENDIAN
b69bbf9b1044 [gaim-migrate @ 4876]
Nathan Walp <nwalp@pidgin.im>
parents: 4581
diff changeset
237 format.byte_format = AO_FMT_BIG;
b69bbf9b1044 [gaim-migrate @ 4876]
Nathan Walp <nwalp@pidgin.im>
parents: 4581
diff changeset
238 afSetVirtualByteOrder(file, AF_DEFAULT_TRACK,
b69bbf9b1044 [gaim-migrate @ 4876]
Nathan Walp <nwalp@pidgin.im>
parents: 4581
diff changeset
239 AF_BYTEORDER_BIGENDIAN);
b69bbf9b1044 [gaim-migrate @ 4876]
Nathan Walp <nwalp@pidgin.im>
parents: 4581
diff changeset
240 #elif __BYTE_ORDER == __LITTLE_ENDIAN
b69bbf9b1044 [gaim-migrate @ 4876]
Nathan Walp <nwalp@pidgin.im>
parents: 4581
diff changeset
241 format.byte_format = AO_FMT_LITTLE;
b69bbf9b1044 [gaim-migrate @ 4876]
Nathan Walp <nwalp@pidgin.im>
parents: 4581
diff changeset
242 afSetVirtualByteOrder(file, AF_DEFAULT_TRACK,
b69bbf9b1044 [gaim-migrate @ 4876]
Nathan Walp <nwalp@pidgin.im>
parents: 4581
diff changeset
243 AF_BYTEORDER_LITTLEENDIAN);
b69bbf9b1044 [gaim-migrate @ 4876]
Nathan Walp <nwalp@pidgin.im>
parents: 4581
diff changeset
244 #endif
4561
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
245
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
246 bytes_per_frame = format.bits * format.channels / 8;
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
247
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
248 device = ao_open_live(ao_driver, &format, NULL);
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
249
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
250 if(device) {
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
251 int frames_read;
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
252 char buf[4096];
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
253 int buf_frames = sizeof(buf) / bytes_per_frame;
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
254
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
255 while((frames_read = afReadFrames(file, AF_DEFAULT_TRACK,
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
256 buf, buf_frames))) {
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
257 if(!ao_play(device, buf, frames_read * bytes_per_frame))
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
258 break;
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
259 }
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
260 ao_close(device);
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
261 }
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
262 afCloseFile(file);
4430
801830dec409 [gaim-migrate @ 4705]
Luke Schierer <lschiere@pidgin.im>
parents: 4429
diff changeset
263 }
4581
4b1e24835bbf [gaim-migrate @ 4864]
Nathan Walp <nwalp@pidgin.im>
parents: 4579
diff changeset
264 ao_shutdown();
4b1e24835bbf [gaim-migrate @ 4864]
Nathan Walp <nwalp@pidgin.im>
parents: 4579
diff changeset
265 #endif /* USE_AO */
1006
0a4d0ed65e17 [gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 899
diff changeset
266 _exit(0);
0a4d0ed65e17 [gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 899
diff changeset
267 }
4581
4b1e24835bbf [gaim-migrate @ 4864]
Nathan Walp <nwalp@pidgin.im>
parents: 4579
diff changeset
268 #else /* USE_NAS_AUDIO || USE_AO */
4561
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
269 gdk_beep();
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
270 return;
4581
4b1e24835bbf [gaim-migrate @ 4864]
Nathan Walp <nwalp@pidgin.im>
parents: 4579
diff changeset
271 #endif /* USE_NAS_AUDIO || USE_AO */
3630
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3367
diff changeset
272 #else /* _WIN32 */
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3367
diff changeset
273 debug_printf("Playing %s\n", filename);
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3367
diff changeset
274 if (!PlaySound(filename, 0, SND_ASYNC | SND_FILENAME))
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3367
diff changeset
275 debug_printf("Error playing sound.");
4561
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
276 #endif /* _WIN32 */
1006
0a4d0ed65e17 [gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 899
diff changeset
277 }
0a4d0ed65e17 [gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 899
diff changeset
278
4561
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
279 void gaim_sound_play_event(GaimSoundEventID event)
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
280 {
4561
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
281 if ((event == GAIM_SOUND_BUDDY_ARRIVE) && mute_login_sounds)
3060
4f2f12bf4408 [gaim-migrate @ 3074]
Sean Egan <seanegan@gmail.com>
parents: 3025
diff changeset
282 return;
4f2f12bf4408 [gaim-migrate @ 3074]
Sean Egan <seanegan@gmail.com>
parents: 3025
diff changeset
283
4561
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
284 if (event >= GAIM_NUM_SOUNDS) {
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
285 debug_printf("got request for unknown sound: %d\n", event);
3060
4f2f12bf4408 [gaim-migrate @ 3074]
Sean Egan <seanegan@gmail.com>
parents: 3025
diff changeset
286 return;
4f2f12bf4408 [gaim-migrate @ 3074]
Sean Egan <seanegan@gmail.com>
parents: 3025
diff changeset
287 }
4f2f12bf4408 [gaim-migrate @ 3074]
Sean Egan <seanegan@gmail.com>
parents: 3025
diff changeset
288
4f2f12bf4408 [gaim-migrate @ 3074]
Sean Egan <seanegan@gmail.com>
parents: 3025
diff changeset
289 /* check NULL for sounds that don't have an option, ie buddy pounce */
4561
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
290 if ((sound_options & sounds[event].opt) || (sounds[event].opt == 0)) {
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
291 if (sound_file[event]) {
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
292 gaim_sound_play_file(sound_file[event]);
3060
4f2f12bf4408 [gaim-migrate @ 3074]
Sean Egan <seanegan@gmail.com>
parents: 3025
diff changeset
293 } else {
4004
b2520034b62f [gaim-migrate @ 4204]
Sean Egan <seanegan@gmail.com>
parents: 3901
diff changeset
294 gchar *filename = NULL;
b2520034b62f [gaim-migrate @ 4204]
Sean Egan <seanegan@gmail.com>
parents: 3901
diff changeset
295
4561
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
296 filename = g_build_filename(DATADIR, "sounds", "gaim", sounds[event].def, NULL);
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
297 gaim_sound_play_file(filename);
4004
b2520034b62f [gaim-migrate @ 4204]
Sean Egan <seanegan@gmail.com>
parents: 3901
diff changeset
298 g_free(filename);
1006
0a4d0ed65e17 [gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 899
diff changeset
299 }
1252
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1235
diff changeset
300 }
64
b1d7336cba85 [gaim-migrate @ 74]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 63
diff changeset
301 }
4561
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
302
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
303 void gaim_sound_set_mute(gboolean mute)
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
304 {
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
305 mute_sounds = mute;
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
306 }
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
307
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
308 gboolean gaim_sound_get_mute()
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
309 {
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
310 return mute_sounds;
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
311 }
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
312
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
313 void gaim_sound_set_login_mute(gboolean mute)
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
314 {
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
315 mute_login_sounds = mute;
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
316 }
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
317
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
318 void gaim_sound_set_event_file(GaimSoundEventID event, const char *filename)
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
319 {
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
320 if(event >= GAIM_NUM_SOUNDS)
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
321 return;
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
322
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
323 if(sound_file[event])
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
324 g_free(sound_file[event]);
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
325
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
326 sound_file[event] = g_strdup(filename);
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
327 }
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
328
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
329
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
330 char *gaim_sound_get_event_file(GaimSoundEventID event)
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
331 {
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
332 if(event >= GAIM_NUM_SOUNDS)
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
333 return NULL;
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
334
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
335 return sound_file[event];
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
336 }
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
337
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
338 guint gaim_sound_get_event_option(GaimSoundEventID event)
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
339 {
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
340 if(event >= GAIM_NUM_SOUNDS)
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
341 return 0;
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
342
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
343 return sounds[event].opt;
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
344 }
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
345
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
346 char *gaim_sound_get_event_label(GaimSoundEventID event)
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
347 {
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
348 if(event >= GAIM_NUM_SOUNDS)
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
349 return NULL;
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
350
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
351 return sounds[event].label;
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
352 }
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
353
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
354
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
355 void gaim_sound_set_command(const char *cmd)
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
356 {
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
357 if(sound_cmd)
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
358 g_free(sound_cmd);
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
359 if(strlen(cmd) > 0)
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
360 sound_cmd = g_strdup(cmd);
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
361 else
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
362 sound_cmd = NULL;
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
363 }
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
364
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
365 char *gaim_sound_get_command()
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
366 {
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
367 return sound_cmd;
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
368 }
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
369