Mercurial > pidgin
comparison src/sound.c @ 4010:2b18ea0ade13
[gaim-migrate @ 4210]
nas should be fixed now
committer: Tailor Script <tailor@pidgin.im>
author | Luke Schierer <lschiere@pidgin.im> |
---|---|
date | Wed, 27 Nov 2002 22:16:20 +0000 |
parents | a9541aded628 |
children | ab6c48a07fd6 |
comparison
equal
deleted
inserted
replaced
4009:a9541aded628 | 4010:2b18ea0ade13 |
---|---|
40 #include <sys/types.h> | 40 #include <sys/types.h> |
41 #include <sys/stat.h> | 41 #include <sys/stat.h> |
42 | 42 |
43 #ifdef ESD_SOUND | 43 #ifdef ESD_SOUND |
44 #include <esd.h> | 44 #include <esd.h> |
45 #endif | |
46 | |
47 #ifdef NAS_SOUND | |
48 #include <audio/audiolib.h> | |
49 #endif | 45 #endif |
50 | 46 |
51 #include "gaim.h" | 47 #include "gaim.h" |
52 | 48 |
53 gboolean mute_sounds = 0; | 49 gboolean mute_sounds = 0; |
152 | 148 |
153 return 1; | 149 return 1; |
154 } | 150 } |
155 | 151 |
156 #endif | 152 #endif |
157 | |
158 #ifdef NAS_SOUND | |
159 | |
160 char nas_server[] = "localhost"; | |
161 AuServer *nas_serv = NULL; | |
162 | |
163 static AuBool NasEventHandler(AuServer * aud, AuEvent * ev, AuEventHandlerRec * handler) | |
164 { | |
165 AuElementNotifyEvent *event = (AuElementNotifyEvent *) ev; | |
166 | |
167 if (ev->type == AuEventTypeElementNotify) { | |
168 switch (event->kind) { | |
169 case AuElementNotifyKindState: | |
170 switch (event->cur_state) { | |
171 case AuStateStop: | |
172 _exit(0); | |
173 } | |
174 break; | |
175 } | |
176 } | |
177 return AuTrue; | |
178 } | |
179 | |
180 static int can_play_nas() | |
181 { | |
182 if ((nas_serv = AuOpenServer(NULL, 0, NULL, 0, NULL, NULL))) | |
183 return 1; | |
184 return 0; | |
185 } | |
186 | |
187 static int play_nas_file(char *file) | |
188 { | |
189 struct stat stat_buf; | |
190 char *buf; | |
191 int ret; | |
192 int fd = open(file, O_RDONLY); | |
193 if (fd <= 0) | |
194 return 0; | |
195 | |
196 if (!can_play_nas()) | |
197 return 0; | |
198 | |
199 if (stat(file, &stat_buf)) | |
200 return 0; | |
201 | |
202 if (!stat_buf.st_size) | |
203 return 0; | |
204 | |
205 buf = malloc(stat_buf.st_size); | |
206 read(fd, buf, stat_buf.st_size); | |
207 ret = play_nas(buf, stat_buf.st_size); | |
208 free(buf); | |
209 return ret; | |
210 } | |
211 | |
212 #endif | |
213 #endif /* !_WIN32 */ | 153 #endif /* !_WIN32 */ |
214 | 154 |
215 void play_file(char *filename) | 155 void play_file(char *filename) |
216 { | 156 { |
217 #ifndef _WIN32 | 157 #ifndef _WIN32 |
263 args[2] = NULL; | 203 args[2] = NULL; |
264 execvp(args[0], args); | 204 execvp(args[0], args); |
265 _exit(0); | 205 _exit(0); |
266 } | 206 } |
267 | 207 |
268 #ifdef NAS_SOUND | |
269 else if (sound_options & OPT_SOUND_NAS) { | 208 else if (sound_options & OPT_SOUND_NAS) { |
270 if (play_nas_file(filename)) | 209 char *args[3]; |
271 _exit(0); | 210 args[0] = "auplay"; |
272 } | 211 args[1] = filename; |
273 #endif | 212 args[2] = NULL; |
274 else if ((sound_options & OPT_SOUND_NORMAL) && | 213 execvp(args[0], args); |
214 } | |
215 else if ((sound_options & OPT_SOUND_NORMAL) && | |
275 can_play_audio()) { | 216 can_play_audio()) { |
276 play_audio_file(filename); | 217 play_audio_file(filename); |
277 _exit(0); | 218 _exit(0); |
278 } | 219 } |
279 | 220 |