comparison src/gtksound.c @ 11082:e25575a59f01

[gaim-migrate @ 13099] Use libao to play stuff over NAS instead of accessing NAS directly. committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Sun, 10 Jul 2005 22:12:37 +0000
parents 50224ac8184d
children bb0d7b719af2
comparison
equal deleted inserted replaced
11081:3fc99df46dae 11082:e25575a59f01
33 33
34 #ifdef USE_AO 34 #ifdef USE_AO
35 # include <ao/ao.h> 35 # include <ao/ao.h>
36 # include <audiofile.h> 36 # include <audiofile.h>
37 #endif /* USE_AO */ 37 #endif /* USE_AO */
38
39 #ifdef USE_NAS_AUDIO
40 # include <audio/audiolib.h>
41 # include <audio/soundlib.h>
42 #endif /* USE_NAS_AUDIO */
43 38
44 #include "debug.h" 39 #include "debug.h"
45 #include "notify.h" 40 #include "notify.h"
46 #include "prefs.h" 41 #include "prefs.h"
47 #include "sound.h" 42 #include "sound.h"
115 110
116 if(!strcmp(val, "esd")) 111 if(!strcmp(val, "esd"))
117 ao_driver = ao_driver_id("esd"); 112 ao_driver = ao_driver_id("esd");
118 else if(!strcmp(val, "arts")) 113 else if(!strcmp(val, "arts"))
119 ao_driver = ao_driver_id("arts"); 114 ao_driver = ao_driver_id("arts");
115 else if(!strcmp(val, "nas"))
116 ao_driver = ao_driver_id("nas");
120 else if(!strcmp(val, "automatic")) 117 else if(!strcmp(val, "automatic"))
121 ao_driver = ao_default_driver_id(); 118 ao_driver = ao_default_driver_id();
122 119
123 if(ao_driver != -1) { 120 if(ao_driver != -1) {
124 ao_info *info = ao_driver_info(ao_driver); 121 ao_info *info = ao_driver_info(ao_driver);
125 gaim_debug_info("sound", 122 gaim_debug_info("sound",
126 "Sound output driver loaded: %s\n", info->name); 123 "Sound output driver loaded: %s\n", info->name);
127 } 124 }
128 #endif /* USE_AO */ 125 #endif /* USE_AO */
129 #ifdef USE_NAS
130 if (!strcmp(val, "nas"))
131 gaim_debug_info("sound",
132 "Sound output driver loaded: NAS output\n");
133 #endif /* USE_NAS */
134 } 126 }
135 127
136 const char * 128 const char *
137 gaim_gtk_sound_get_event_option(GaimSoundEventID event) 129 gaim_gtk_sound_get_event_option(GaimSoundEventID event)
138 { 130 {
218 sound_initialized = FALSE; 210 sound_initialized = FALSE;
219 211
220 gaim_debug_unregister_category("sound"); 212 gaim_debug_unregister_category("sound");
221 } 213 }
222 214
223 #ifdef USE_NAS_AUDIO 215 #if defined(USE_AO)
224 static gboolean
225 play_file_nas(const char *filename)
226 {
227 AuServer *nas_serv;
228 gboolean ret = FALSE;
229
230 if((nas_serv = AuOpenServer(NULL, 0, NULL, 0, NULL, NULL))) {
231 ret = AuSoundPlaySynchronousFromFile(nas_serv, filename, 100);
232 AuCloseServer(nas_serv);
233 }
234
235 return ret;
236 }
237
238 #endif /* USE_NAS_AUDIO */
239
240 #if defined(USE_NAS_AUDIO) || defined(USE_AO)
241 static gboolean 216 static gboolean
242 expire_old_child(gpointer data) 217 expire_old_child(gpointer data)
243 { 218 {
244 int ret; 219 int ret;
245 pid_t pid = GPOINTER_TO_INT(data); 220 pid_t pid = GPOINTER_TO_INT(data);
258 233
259 static void 234 static void
260 gaim_gtk_sound_play_file(const char *filename) 235 gaim_gtk_sound_play_file(const char *filename)
261 { 236 {
262 const char *method; 237 const char *method;
263 #if defined(USE_NAS_AUDIO) || defined(USE_AO) 238 #if defined(USE_AO)
264 pid_t pid; 239 pid_t pid;
265 #ifdef USE_AO 240 #ifdef USE_AO
266 AFfilehandle file; 241 AFfilehandle file;
267 #endif 242 #endif
268 #endif 243 #endif
318 } 293 }
319 294
320 g_free(command); 295 g_free(command);
321 return; 296 return;
322 } 297 }
323 #if defined(USE_NAS_AUDIO) || defined(USE_AO) 298 #if defined(USE_AO)
324 pid = fork(); 299 pid = fork();
325 if (pid < 0) 300 if (pid < 0)
326 return; 301 return;
327 else if (pid == 0) { 302 else if (pid == 0) {
328 #ifdef USE_NAS_AUDIO
329 if (!strcmp(method, "nas")) {
330 if (play_file_nas(filename))
331 _exit(0);
332 }
333 #endif /* USE_NAS_AUDIO */
334
335 #ifdef USE_AO 303 #ifdef USE_AO
336 file = afOpenFile(filename, "rb", NULL); 304 file = afOpenFile(filename, "rb", NULL);
337 if(file) { 305 if(file) {
338 ao_device *device; 306 ao_device *device;
339 ao_sample_format format; 307 ao_sample_format format;
385 #endif /* USE_AO */ 353 #endif /* USE_AO */
386 _exit(0); 354 _exit(0);
387 } else { 355 } else {
388 gaim_timeout_add(PLAY_SOUND_TIMEOUT, expire_old_child, GINT_TO_POINTER(pid)); 356 gaim_timeout_add(PLAY_SOUND_TIMEOUT, expire_old_child, GINT_TO_POINTER(pid));
389 } 357 }
390 #else /* USE_NAS_AUDIO || USE_AO */ 358 #else /* USE_AO */
391 gdk_beep(); 359 gdk_beep();
392 return; 360 return;
393 #endif /* USE_NAS_AUDIO || USE_AO */ 361 #endif /* USE_AO */
394 #else /* _WIN32 */ 362 #else /* _WIN32 */
395 gaim_debug_info("sound", "Playing %s\n", filename); 363 gaim_debug_info("sound", "Playing %s\n", filename);
396 364
397 if (G_WIN32_HAVE_WIDECHAR_API ()) { 365 if (G_WIN32_HAVE_WIDECHAR_API ()) {
398 wchar_t *wc_filename = g_utf8_to_utf16(filename, 366 wchar_t *wc_filename = g_utf8_to_utf16(filename,